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
  unrestricted simplex protocol in computer network in c program Guest 1 0 25-10-2017 04:25 PM
Last Post: jaseela123
  verilog program for diffie hellman algorithm Guest 1 175 11-10-2017 10:13 AM
Last Post: jaseela123
Wink verification of time division multiplexing using matlab program Guest 1 145 10-10-2017 02:45 PM
Last Post: jaseela123
  simulation of extra high voltage long transmission lines matlab program Guest 1 274 09-10-2017 11:12 AM
Last Post: jaseela123
Question matlab program for handover in lte network Guest 1 268 07-10-2017 12:25 PM
Last Post: jaseela123
  embedded c program for rfid based toll gate control Guest 1 126 06-10-2017 11:17 AM
Last Post: jaseela123
  night light saver electronics mini project circuit and program Guest 1 742 06-10-2017 11:09 AM
Last Post: jaseela123
  java servlet program to display student mark list Guest 1 153 03-10-2017 12:11 PM
Last Post: jaseela123
  verilog program for diffie hellman algorithm Guest 1 157 03-10-2017 10:37 AM
Last Post: jaseela123
  matlab program for image halftoning Guest 1 188 02-10-2017 11:18 AM
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: