first and follow
Ex-6 Write a C program to compute the First and Follow sets for the given Grammar /* A=aAbA B=bBaB A=a B=b */ #include<stdio.h> #include<math.h> #include<string.h> #include<ctype.h> #include<stdlib.h> int n,m=0,p,i=0,j=0; char a[10][10],f[10]; void follow(char c); void first(char c); int main(){ int i,z; char c,ch; printf("Enter the no of prooductions:\n"); scanf("%d",&n); printf("Enter the productions:\n"); for(i=0;i<n;i++) scanf("%s%c",a[i],&ch); do{ m=0; printf("Enter the elemets whose fisrt & follow is to be found:"); scanf("%c",&c); first(c); printf("First(%c)={",c); for(i=0;i<m;i++) printf("%c",f[i]); printf("}\n"); strcpy(f," "); //flushall(); m=0; follow(c); printf("Follow(%c)={",c);...