Deenbandhu Chhotu Ram University of Science and Technology
Deenbandhu Chhotu Ram University of Science and Technology
#include<stdio.h>
#define max 100
void main()
{
char str[max],f='a';
int i;
printf("enter the string to be checked: ");
scanf("%s",str);
for(i=0;str[i]!=NULL;i++)
{
switch(f)
{
case 'a': if(str[i]=='0') f='b';
else if(str[i]=='1') f='a';
break;
case 'b': if(str[i]=='0') f='b';
else if(str[i]=='1') f='c';
break;
case 'c': if(str[i]=='0') f='c';
else if(str[i]=='1') f='c';
break;
}
}
if(f=='c')
printf("String is accepted as it reaches the final state that is %c.",f);
else
printf("String is not accepted as it reaches the state %c which is not a
final state.",f);
}
OUTPUT