Important: Use custom search function to get better results from our thousands of pages

Use " " for compulsory search eg:"electronics seminar" , use -" " for filter something eg: "electronics seminar" -"/tag/" (used for exclude results from tag pages)


 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Program in “C” to implement DFA.
Post: #1

Objective
Program in “C” to implement DFA.


Code:
#include<stdio.h>
#include<conio.h>
void main()
{
  int state[10];
  int str[10],input[10];
  char ch;
  int x[20];
  int s,n,k=0,j,a,i,l,t,q=0,fs,b,nxt;
  clrscr();
  printf("enter the no. states\n");
  scanf("%d",&s);
  printf("enter the no.of i/ps\n");
  scanf("%d",&n);
  for(i=0;i<s;i++)
  {
printf("enter the state\n");
scanf("%d",&state[i]);
printf("is it final state?... .y..1/n..0\n");
scanf("%d",&a);
if(a==1)
        fs=state[i];
  }
  printf("enter the i/ps\n");
  for(i=0;i<n;i++)
      scanf("%d",&input[i]);
  printf("transition state\n");
  
  for(i=0;i<s;i++)
  {
for(j=0;j<n;j++)
      {
printf("(q%d,%d)=q",state[i],input[j]);
scanf("%d",&b);
        x[k]=b; k++;
    }
  }
  printf("enter the length of string\n");
  scanf("%d",&l);
  printf("enter the i/p string\n");
  for(i=0;i<l;i++)
      scanf("%d",&str[i]);
  for(i=0;i<l;i++)
  {
      t=0;
     do
      {
          if(str[i]==input[t])
          {
              nxt=x[n*q+t];
for(j=0;j<s;j++)
{
              if(nxt==state[j])
                  q=j;
}
t++;
          }
          
           else
              t++;
     }
     while(t!=n);
  }
  if(nxt==fs)
      printf("\n string is accepted\n");
  else
      printf("\n not accepted\n");
  getch();
}
Post: #2
Plz give me a suitable output for this dfa program
Post: #3
i need a c program to implement a dfa simulator ..such that the program should run for all the dfa's given as input
Post: #4
Program in “C” to implement DFA

#include<stdio.h>
#include<conio.h>
void main()
{
int state[10];
int str[10],input[10];
char ch;
int x[20];
int s,n,k=0,j,a,i,l,t,q=0,fs,b,nxt;
clrscr();
printf("enter the no. states\n");
scanf("%d",&s);
printf("enter the no.of i/ps\n");
scanf("%d",&n);
for(i=0;i<s;i++)
{
printf("enter the state\n");
scanf("%d",&state[i]);
printf("is it final state?... .y..1/n..0\n");
scanf("%d",&a);
if(a==1)
fs=state[i];
}
printf("enter the i/ps\n");
for(i=0;i<n;i++)
scanf("%d",&input[i]);
printf("transition state\n");

for(i=0;i<s;i++)
{
for(j=0;j<n;j++)
{
printf("(q%d,%d)=q",state[i],input[j]);
scanf("%d",&b);
x[k]=b; k++;
}
}
printf("enter the length of string\n");
scanf("%d",&l);
printf("enter the i/p string\n");
for(i=0;i<l;i++)
scanf("%d",&str[i]);
for(i=0;i<l;i++)
{
t=0;
do
{
if(str[i]==input[t])
{
nxt=x[n*q+t];
for(j=0;j<s;j++)
{
if(nxt==state[j])
q=j;
}
t++;
}

else
t++;
}
while(t!=n);
}
if(nxt==fs)
printf("\n string is accepted\n");
else
printf("\n not accepted\n");
getch();
}
 

Marked Categories : c code for implementation of dfa, implementing dfa in c, dfa program in c, dfa programming in c, program in c of dfa, c programing implimwnting dfa, implementation of dfa accept any string in c, c program implimenting dfa, implement dfa using c proram, program in c for dfa, dfa programming inc, c program for dfa, implementing dfa through c, program in c to implement dfa, program to implement dfa in c, dfa implimentation in c, c program for a dfa, c program to implement dfa, dfa c program, how to implement a dfa in c, c program for implementing a dfa, dfa c code, dfa program in c language, implementation of c program for dfa, dfa implementation in c, c program of dfa,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Image Verification
(case insensitive)
Please enter the text within the image on the left in to the text box below. This process is used to prevent automated posts.

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
Thumbs Up pic16f73 led blink program Guest 0 0 24-06-2017 11:05 PM
Last Post: Guest
  automatic night lamp with morning alarm using 8086 assembly language program Guest 0 0 15-06-2017 11:39 AM
Last Post: Guest
  training program in electronics and communication Guest 1 0 12-06-2017 11:08 AM
Last Post: jaseela123
Thumbs Up bit stuffing program using udp socket Guest 1 0 29-05-2017 03:44 PM
Last Post: jaseela123
  assembly language program for metro train prototype using 8051 Guest 1 0 29-05-2017 01:36 PM
Last Post: jaseela123
  matlab program for economic load dispatch Guest 1 0 05-05-2017 03:18 PM
Last Post: jaseela123
  digital clock program using 8085 microprocessor Guest 1 0 04-05-2017 03:43 PM
Last Post: jaseela123
  yacc program to convert binary to decimal Guest 1 0 03-05-2017 02:40 PM
Last Post: jaseela123
  matlab program for extended equal area criterion Guest 1 185 25-04-2017 12:59 PM
Last Post: jaseela123
  c program to implement dijkstra s algorithm using ospf protocol Guest 1 153 25-04-2017 12:56 PM
Last Post: jaseela123
This Page May Contain What is Program in “C” to implement DFA. And Latest Information/News About Program in “C” to implement DFA. ,If Not ...Use Search to get more info about Program in “C” to implement DFA. Or Ask Here

Options: