#include
#include
int main()
{ char ch='y';
char ss[10];
int i, size;
clrscr();
cout<<"\nThe grammar is a*ab";
do
{
cout<<"\nenter the size";
cin>>size ;
cout<<"\nenter the string";
for(i=0;i
cin>>ss[i];
}
if(ss[size-1]=='b' && ss[size-2]=='a')
{
for(i=0;i<=size-3;i++)
{
if(ss[i]=='a')
cout<<"\n"<<"Correct string:accepted by the grammar";
}
}
else
cout<<"\nincorrect string REJECTED!!!";
cout<<"\npress y to continue...";
cin>>ch;
}
while(ch=='y'|| ch=='Y');
getch();
return 0;
}