0% found this document useful (0 votes)
93 views2 pages

Regular Expression in C

this tell us about the data models which we study in automata like DFA, MFA etc. this is basically for those who are interested in lab sessions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views2 pages

Regular Expression in C

this tell us about the data models which we study in automata like DFA, MFA etc. this is basically for those who are interested in lab sessions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Problem: C Program for implementing DFA of Regular Expression

(a+aa*b)*
In this program you have to enter a string and output will be shown as whether string will be accepted or
not. Program is implemented using transition table not jumping on different states. It can be easily
modifiable for other regular expressions.





#include<stdio.h>
#include<conio.h>
#include<strings.h>

void main()
{
int table[2][2],i,j,l,status=0,success;
char input[100];
printf("Program for implmenting DFA of language
(a+aa*b)*\n\n\nEnter Input String \n");
table[0][0]=1;
table[0][1]=-1;
table[1][0]=1;
table[1][1]=0;
scanf("%s",input);
l=strlen(input);

for(i=0;i<l;i++)
{
if(input[i]!='a'&&input[i]!='b')
{
printf("Value entered is wrong");
getch();
exit(0);
}
if(input[i]=='a')
status=table[status][0];
else
status=table[status][1];

if(status==-1)
{
printf("String not Accepted by this Language");
break;
}
}
if(i==l)
printf("String Accepted");
getch();
}


OUTPUT:

You might also like