answersLogoWhite

0

#include"stdio.h"

#include<conio.h>

#define max 10

#define MAX 15

char array[max][MAX],temp[max][MAX];

int c,n,t;void fun(int,int[]);

int fun2(int i,int j,int p[],int key)

{

int k;

if(!key)

{

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

if(array[i][j]==array[k][0])

break;

p[0]=i;p[1]=j+1;

fun(k,p);

return 0;

}

else

{

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

{

if(array[i][j]==temp[t][k])

break;

}

if(k>c)return 1;

else return 0;

}

}

void fun(int i,int p[])

{

int j,k,key;

for(j=2;array[i][j]!='\0';j++)

{

if(array[i][j-1]=='/')

{

if(array[i][j]>='A'&&array[i][j]<='Z')

{

key=0;

fun2(i,j,p,key);

}

else

{key=1;

if(fun2(i,j,p,key))

temp[t][++c]=array[i][j];

if(array[i][j]=='[at]'&&p[0]!=-1)

{ //taking ,[at], as null symbol.

if(array[p[0]][p[1]]>='A'&&array[p[0]][p[1]]<='Z')

{

key=0;

fun2(p[0],p[1],p,key);

}

else

if(array[p[0]][p[1]]!='/'&&array[p[0]][p[1]]!='\0')

{

if(fun2(p[0],p[1],p,key))

temp[t][++c]=array[p[0]][p[1]];

}

}

}

}

}

}

char fol[max][MAX],ff[max];int f,l,ff0;

void ffun(int,int);

void follow(int i)

{

int j,k;

for(j=0;j<=ff0;j++)

if(array[i][0]==ff[j])

return 0;

if(j>ff0)ff[++ff0]=array[i][0];

if(i==0)fol[l][++f]='$';

for(j=0;j<n;j++)

for(k=2;array[j][k]!='\0';k++)

if(array[j][k]==array[i][0])

ffun(j,k);

}

void ffun(int j,int k)

{

int ii,null=0,tt,cc;

if(array[j][k+1]=='/'array[j][k+1]=='\0')

null=1;

for(ii=k+1;array[j][ii]!='/'&&array[j][ii]!='\0';ii++)

{

if(array[j][ii]<='Z'&&array[j][ii]>='A')

{

for(tt=0;tt<n;tt++)

if(temp[tt][0]==array[j][ii])break;

for(cc=1;temp[tt][cc]!='\0';cc++)

{

if(temp[tt][cc]=='[at]')null=1;

else fol[l][++f]=temp[tt][cc];

}

}

else fol[l][++f]=array[j][ii];

}

if(null)follow(j);

}

void main()

{

int p[2],i,j;

clrscr();

printf("Enter the no. of productions :");

scanf("%d",&n);

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

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

scanf("%s",array[i]);

for(i=0,t=0;i<n;i++,t++)

{

c=0,p[0]=-1,p[1]=-1;

temp[t][0]=array[i][0];

fun(i,p);

temp[t][++c]='\0';

printf("First(%c) : [ ",temp[t][0]);

for(j=1;j<c;j++)

printf("%c,",temp[t][j]);

printf("\b ].\n");

getch();

}

/* Follow Finding */

for(i=0,l=0;i<n;i++,l++)

{

f=-1;ff0=-1;

fol[l][++f]=array[i][0];

follow(i);

fol[l][++f]='\0';

}

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

{

printf("\nFollow[%c] : [ ",fol[i][0]);

for(j=1;fol[i][j]!='\0';j++)

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

printf("\b ]");

getch();

}

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Continue Learning about Engineering

How do you find execution time of a program in java?

You can have the below line as the first and last line of the program and find out the difference in time taken to calculate the execution time. This will print the system time in the console which can be used to calculate execution time.System.currentTimeMillis();


Was hello world the content of the first computer program?

No, "Hello world" is typically the first program assignment in introductory computer programming classes as it is trivial to write and almost useless.


Draw a flowchart that will ask the user to enter 10 numbers and calculate the average?

Sure thing, sweetheart. First, you'll need a start symbol followed by a process symbol to input the numbers. Connect that to a decision symbol asking if 10 numbers have been entered yet. If not, loop back to the input process. Once all 10 numbers are in, use a process symbol to calculate the average and finally end with an output symbol displaying the average. Easy peasy lemon squeezy!


How many HTML codes are there?

Before i answer,first it is there,not their (learn grammar...) The answer is about 1 trillion (and a half)


Which flowcharts symbol is used for opening and closing files?

rectangle Flowchart represent the algorithm or process of data, using chart or sysmbols. There are different Flowchart symbols. the ff. are: 1. Terminal sysmbol - (oval) this symbol represent the start and end of the flowchart. 2. Initialization Symbol - (hexagon) this symbol is used in declaring or initializing variable used in the program. 3. Process Symbol (Rectangle) this symbol used in calculation, opening and closing file paths. 4. Condition Symbol (Diamond) this symbol used in condition of value in programming. this condition have a one entrance two exit which is the first exit is the "TRUE STATEMENT" and other exit is the "FALSE STATENENT". 5. Input and Output Symbol (parallelogram) this symbol used in input and output of the program. there is one entrance and one exit. 6. Connector (small Circle) it is used in connection flowchart that does not adjacent of not the same patcular area. 7. Arrow Lines (arrow) this is used to connect or the direction or flow of data. source: http://jaypeeworldprogrammer.blogspot.com/2010/06/flowchart.html

Related Questions

Write a program to calculate first?

int first= 1;


How do you find execution time of a program in java?

You can have the below line as the first and last line of the program and find out the difference in time taken to calculate the execution time. This will print the system time in the console which can be used to calculate execution time.System.currentTimeMillis();


What is the program to calculate the average of first 'n' natural numbers?

printf ("%g\n", (n+1.0)/2);


Who wrote the first grammar book short introduction to the English grammar in 1762?

In fact, Robert Lowth wrote "Short Introduction to English Grammar" in 1762 and it is seen as the first grammar book because there was a real explosion of grammar in the 1760's but the first real grammar book was written by William Bullokar. In 1586 Bullokar wrote "Pamphlet for Grammar" . Of course it wasn't as complete as Lowth's work but it is the first real English grammar book. Source: The Oxford History of English


How do you introduce yourself the first day in college in an MBA program?

First, use better grammar: "How should I introduce myself on first day of an MBA curriculum?" Getting to the point: "Hello. I am Andrew Matej. And you are?"


When was Urmston Grammar School founded?

Urmston Grammar school was first established in 1882.


When working with the spelling and grammar dialog box before you make a decision on the first grammar change what command stops the grammar check?

cancel


Was hello world the content of the first computer program?

No, "Hello world" is typically the first program assignment in introductory computer programming classes as it is trivial to write and almost useless.


Who wrote the first grammar in sanskrit?

The first grammar in Sanskrit was written by Panini, an ancient Indian grammarian, who is known for his work &quot;Ashtadhyayi.&quot; This grammar text is highly revered for its detailed rules and structure governing the Sanskrit language.


A cup of coffee first while waiting for our breakfast meal is a correct grammar?

Yes, the grammar in that sentence is correct.


Use the word grammar school in a sentence?

Most of the grammar is taught in grammar school. China has highest grammar schools in the world.


What has the author Gwas Kenethlow written?

Gwas Kenethlow. has written: 'Grammar for the first grade and the auxiliary verbs' 'Grammar for the second grade' 'Grammar for the first frade' 'Whethlow Noweth Ha Coth' 'Hwedhlow nowydh ha koth ='