You are on page 1of 2

Program: #include<stdio.h> #include<conio.h> #include<string.

h> int s=0; struct sys { int v; char sym[10]; }sys[10]; void create(); void insert(); void search(); void display(); void mod(); void main() { int c; clrscr(); do { printf("SYMBOL TABLE\n1.create\n2.insert\n3.search\n4.display\n5.modify\n6.exit\nEnter your choice:"); scanf("%d",&c); switch(c) { case 1: create(); break; case 2: insert(); break; case 3: search(); break; case 4: display(); break; case 5: mod(); break; }} while(c!=6); } void create() { insert(); getch(); } void insert() { int i,n; printf("Enter the no of symbols"); scanf("%d",&n); for(i=0;i<n;i++) { printf("Enter the symbols:"); scanf("%s",&sys[s].sym); printf("Enter the address for %s :",sys[s].sym); scanf("%d",&sys[s].v);

s++; }} void search() { int i; char se[10]; printf("Enter the symbol to search"); scanf("%s",se); for(i=0;i<s;i++) { if(strcmp(sys[i].sym,se)==0) { printf("The symbol is found in the position %d is address %d...",i+1,sys[i].v); break; }} if(i==s) printf("Symbol is not found..."); getch(); } void mod() { char se[10]; int i,j,k,t; printf("Enter the symbol to modify"); scanf("%s",se); for(i=0;i<s;i++) { if(strcmp(sys[i].sym,se)==0) { printf("Enter the address"); scanf("%d",&sys[i].v); break; }} if(i==s) printf("The symbol is not found"); } void display() { int i; printf("\nSYMBOL TABLE\n-------------\t\n "); for(i=0;i<s;i++) { printf("%s\t%d\n\n",sys[i].sym,sys[i].v); }}

You might also like