48. Writer a C program which store students name, id and gpa. and make a serach option that when we enter a name for search, if the name is there then show that students name,id and gpa. If the name is not there then show NOT FOUND!.



#include<stdio.h>
#include<conio.h>
#include<string.h>
struct student
{
char name[40];
char id[20];
char gpa[5];
}stu[100];
void main()
{
clrscr();
int i=0,j,n;
char name[40];
printf("How many students informatio: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nEnter the name: ");
scanf("%s",stu[i].name);
printf("\nEnter the id: ");
scanf("%s",stu[i].id);
printf("\nEnter the gpa: ");
scanf("%s",stu[i].gpa);
clrscr();
}
printf("\nEnter the search name: ");
scanf("%s",name);
for(i=0;i<n;i++)
{
clrscr();
j=strcmp(name,stu[i].name);
if(j==0)
{
printf("\nName :");
puts(stu[i].name);
printf("\nId :");
puts(stu[i].id);
printf("\nGPA :");
puts(stu[i].gpa);
break;
}
}
if(j!=0)
printf("Not found !");
getch();
}

program written by arnob;

No comments:

Post a Comment

free counters