You are on page 1of 2

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

h> struct symbolTable{ char name[10]; char add[10]; char value[10]; int size; }; void main(){ struct symbolTable table[10]; int i=0; char check='n'; char name[20]; int j; do{ clrscr(); printf("symbol table \n"); printf("Enter name : address : value : size ::-\n"); scanf("%s%s%s%d",&table[i].name , &table[i].add , &table[i].valu e , &table[i].size); i++; printf("no. of record filled :%d \n Want to add more symbol(y/n) :",i); fflush(stdin); scanf("%c",&check); }while(check == 'y' check == 'Y'); printf("Name, add, value , size\n"); j=0; while(j<i) { printf("%s \t %s \t %s \t %d \n",table[j].name , table[j].add , table[j].value , table[j].size); j++; } printf("search element by 'name':"); scanf("%s",name); for(j=0;j<i;j++) { if(!strcmp(table[j].name,name)) { printf("symbol at %d pos \n",i+1); printf("data of symbol:\n %s \t %s \t %s \t %d \n",table [j].name,table[j].add,table[j].value,table[j].size); break; } } if(j==i) printf("symbol not found"); getch(); } /* output::symbol table Enter name : address : value : size ::pqr 1234 null 2 no. of record filled :1 Want to add more symbol(y/n):y

symbol table Enter name : address : value : size ::xyz 1234 name 4 no. of record filled :2 Want to add more symbol(y/n):n Name, add, value , size abc 1234 null 2 xyz 1234 name 4 search element by 'name':abc symbol at 3 pos data of symbol: abc 1234 null 2 */

You might also like