#include
#include
/*Write a Program to create a
*
Structure that has
name of student,
Roll number,
mark1, mark2, and mark3
are the member variables to maintain many records.
If I want to access particular record,
then you should search the records
based on either their name or their roll number.*/
//int n;
struct stu
{
char name[50];
int rollno;
int mark1,mark2,mark3;
}b[100];
int main()
{
char data[50];
int i,n,key,flag=0;
printf("enter the number of students record in database\n");
scanf("%d",&n);
printf("enter the student details in the following sequence\n");
printf("name,rollno,mark1,mark2,mark3\n");
for(i=0;i<n;i++)
{
printf("\tenter the %d student details\n",i+1);
scanf("%s%d%d%d%d",b[i].name,&b[i].rollno,&b[i].mark1,&b[i].mark2,&b[i].mark3);
}
printf("****database details**");
for(i=0;i
printf(" \n \nthe %d student details\n\n",i+1);
printf("\nname %s\t rollno %6.d\t mark1 %6.d\t mark2 %6.d\t mark3 %6.d",b[i].name,b[i].rollno,b[i].mark1,b[i].mark2,b[i].mark3);
}
printf("\nenter the particular students rollno\n");
scanf("%d",&key);
for(i=0;i
if(key==b[i].rollno)
{
printf("\n****found***\n");
printf("\n name %s\trollno %d\tmark1 %d\tmark2 %d\tmark3 %d\n",b[i].name,b[i].rollno,b[i].mark1,b[i].mark2,b[i].mark3);
flag=1;
}
}
if(flag==0)
{
printf("\n***not found**\n");
}
flag=0;
printf("\n enter the particular students name\n");
scanf("%s",data);
for(i=0;i
if(strcmp(data,b[i].name)==0)
{
printf("\n****found***\n");
printf("\n name %s\trollno %d\tmark1 %d\tmark2 %d\tmark3 %d\n",b[i].name,b[i].rollno,b[i].mark1,b[i].mark2,b[i].mark3);
flag=1;
}
}
if(flag==0)
{
printf("\n***not found**\n");
}
getch();
return 0;
}
No comments:
Post a Comment