Untitled

 avatar
unknown
plain_text
a year ago
3.1 kB
6
Indexable
/*Design DFA for accepting the language aab in c-program*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
	int initial_state=1, len, current_state=1;
	char a,b,str[10];
	printf("enter your string:");
	scanf("%s",&str);
	len=strlen(str);
	if(len=)
	{
		if(initial_state==1 && str[0]=='a')
		{
			current_state=2;
	      initial_state++;
			
		if(initial_state==2 && str[1]=='b')
		{
			current_state=3;
			initial_state++;
		
			if(initial_state==3 && str[2]=='b')
		{
			current_state=4;
			initial_state++;
			
			printf("string is accepted");
	}
}
}
}
		else
		printf("string is rejected");		
}



/*Design DFA for accepting the language aab in c-program*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
	int initial_state=1, len, current_state=1;
	char a,b,str[10];
	printf("enter your string:");
	scanf("%s",&str);
	len=strlen(str);
	if(len=6)
	{
		if(initial_state==1 && str[0]=='a')
		{
			current_state=2;
	      initial_state++;
			
		if(initial_state==2 && str[1]=='a')
		{
			current_state=3;
			initial_state++;
				if(initial_state==3 && str[2]=='a')
		{
			current_state=4;
			initial_state++;
				if(initial_state==4 && str[3]=='b')
		{
			current_state=5;
			initial_state++;
				if(initial_state==5 && str[4]=='b')
		{
			current_state=6;
			initial_state++;
		
			if(initial_state==6 && str[5]=='b')
		{
			current_state=7;
			initial_state++;
			
			printf("string is accepted");
	}
}
}
}
}
}
}
		else
		printf("string is rejected");		
}


/*Design DFA for accepting the language aab in c-program*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
	int initial_state=1, len, current_state=1;
	char a,b,str[10];
	printf("enter your string:");
	scanf("%s",&str);
	len=strlen(str);
	if(str[len-1]=='0'&& str[len-2]=='0')
	{
		printf("accepted!!!!!!!");
	}
	else
	{
		printf("sorry");
	}
}

/*Design DFA for accepting the language aababa in c-program*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
	int initial_state=1, len, current_state=1;
	char a,b,str[10];
	printf("enter your string:");
	scanf("%s",&str);
	len=strlen(str);
	if(len=7)
	{
		if(initial_state==1 && str[0]=='a')
		{
			current_state=2;
	      initial_state++;
			
		if(initial_state==2 && str[1]=='a')
		{
			current_state=3;
			initial_state++;
				if(initial_state==3 && str[2]=='b')
		{
			current_state=4;
			initial_state++;
				if(initial_state==4 && str[3]=='a')
		{
			current_state=5;
			initial_state++;
				if(initial_state==5 && str[4]=='b')
		{
			current_state=6;
			initial_state++;
		
			if(initial_state==6 && str[5]=='a')
		{
			current_state=7;
			initial_state++;
				if(initial_state==7 && str[5]=='a')
		{
			current_state=8;
			initial_state++;
			
			printf("string is accepted");
	}
}
}
}
}
}
}
}
		else
		printf("string is rejected");		
}
Editor is loading...
Leave a Comment