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();
}
 


[-]
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.
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
  buzzer program for at89s51 Guest 1 0 02-03-2017 09:41 AM
Last Post: jaseela123
  hostel mess management system c program code Guest 1 0 25-02-2017 10:17 AM
Last Post: ijasti
  program in assembly language of eight player quiz buzzer using 8051 microcontroller Guest 1 0 25-02-2017 10:04 AM
Last Post: ijasti
Wink c program for coin operated mobile charger Guest 1 0 24-02-2017 09:05 AM
Last Post: jaseela123
  c program and procedure to implement noise cancellation in dsk 6713 Guest 1 0 10-02-2017 02:41 PM
Last Post: jaseela123
  implementation of digital signature using rsa algorithm using code or c program Guest 1 0 09-02-2017 09:34 AM
Last Post: jaseela123
  bb84 program code in matlab phys 1 0 06-02-2017 12:08 PM
Last Post: ijasti
  verilog code to implement nikhilam sutra Guest 1 0 03-02-2017 11:22 AM
Last Post: jaseela123
  pso based pid tuning program in matlab Guest 1 0 01-02-2017 11:29 AM
Last Post: jaseela123
  finger print program using microcontroller Guest 0 0 04-01-2017 09:19 PM
Last Post: Guest
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: