#include
#include
void main()
{
int age[50],n,i,sage,flag=0;
char yn,name[50][50];
clrscr();
printf("Enter Number of Student : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter Name of Student %d : ",i);
scanf("%s",name[i]);
printf("Enter Age of %s : ",name[i]);
scanf("%d",&age[i]);
}
do
{
clrscr();
flag=0;
printf("\tS.No\tNAME\tAGE");
for(i=1;i<=n;i++)
{
printf("\n\t%d\t%s\t%d",i,name[i],age[i]);
}
printf("\nEnter Student Age to Find Name and S.No : ");
scanf("%d",&sage);
for(i=1;i<=n;i++)
{
if(age[i]==sage)
{
printf("\n\tS.No : %d\n\tName : %s\n\tAge : %d\n",i,name[i],age[i]);
flag=1;
}
}
if(flag==0)
printf("\nStudent Age %d is not in our record.",sage);
printf("\nDo you Want to Continue (Y/y) : ");
yn=getchar();
}while((yn=='Y')(yn=='y'));
getch();
}
Output
Enter Number of Student : 3
Enter Name of Student 1 : c
Enter Age of c : 1
Enter Name of Student 2 : b
Enter Age of b : 3
Enter Name of Student 3 : a
Enter Age of a : 2
S.No NAME AGE
1 c 1
2 b 3
3 a 2
Enter Student Age to Find Name and S.No : 3
S.No : 2
Name : b
Age : 3
Do you Want to Continue (Y/y) :n
No comments:
Post a Comment