answersLogoWhite

0

#include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

{

char t[5],nt[10],p[5][5],first[5][5],temp;

int i,j,not,nont,k=0,f=0;

clrscr();

printf("\nEnter the no. of Non-terminals in the grammer:");

scanf("%d",&nont);

printf("\nEnter the Non-terminals in the grammer:\n");

for(i=0;i<nont;i++)

{

scanf("\n%c",&nt[i]);

}

printf("\nEnter the no. of Terminals in the grammer: ( Enter e for absiline ) ");

scanf("%d",&not);

printf("\nEnter the Terminals in the grammer:\n");

for(i=0;i<nott[i]=='$';i++)

{

scanf("\n%c",&t[i]);

}

for(i=0;i<nont;i++)

{

p[i][0]=nt[i];

first[i][0]=nt[i];

}

printf("\nEnter the productions :\n");

for(i=0;i<nont;i++)

{

scanf("%c",&temp);

printf("\nEnter the production for %c ( End the production with '$' sign )

:",p[i][0]);

for(j=0;p[i][j]!='$';)

{

j+=1;

scanf("%c",&p[i][j]);

}

}

for(i=0;i<nont;i++)

{

printf("\nThe production for %c -> ",p[i][0]);

for(j=1;p[i][j]!='$';j++)

{

printf("%c",p[i][j]);

}

}

for(i=0;i<nont;i++)

{

f=0;

for(j=1;p[i][j]!='$';j++)

{

for(k=0;k<not;k++)

{

if(f==1)

break;

if(p[i][j]==t[k])

{

first[i][j]=t[k];

first[i][j+1]='$';

f=1;

break;

}

else if(p[i][j]==nt[k])

{

first[i][j]=first[k][j];

if(first[i][j]=='e')

continue;

first[i][j+1]='$';

f=1;

break;

}

}

}

}

for(i=0;i<nont;i++)

{

printf("\n\nThe first of %c -> ",first[i][0]);

for(j=1;first[i][j]!='$';j++)

{

printf("%c\t",first[i][j]);

}

}

getch();

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

C program on how to calculate circumference of a circle?

int radius = 2; int output; radius = radius * 2; output = radius * Math.PI; Console.WriteLine(output);


How do you write a c program that prints a box an oval an arrow and a diamond?

You first learn how to program in C.


How do you write socket program in c?

For first find an example program.


What is c program to calculate product of all even numbers from entered number down to 1?

c is programming laungage


How do you write a C plus plus program that will display the first 10 positive prime numbers?

By learning how to program on C+.


How do you compile a c program in windows OS?

First, install a C-compiler.


How can program for c language?

first think of the logic and then write the statements


How do you write an Algorithm for a C plus plus Program?

You don't write an algorithm for a C++ program, unless you are documenting the C++ program after-the-fact. The normal procedure is to write the algorithm first, in a language independent fashion, and then translate that stated algorithm into C++ code, or into whatever language you wish.


Who is the founder of turbo c program?

Turbo c program is from Borland which is an integrated development environment and a computer language. Some of the parts of turbo c were incorporated from the wizard c in 1987, but it was first developed by Dennis Ritchie in 1970.


The first major program written in C was the what opserating system?

Unix kernel


Features of c program?

the features of a C program


C program was introduced in the year?

c program was introduced in the year 1972 by Dennis RitchieNo, it was the C language, not the C program.