PROGRAM TO WRITE DATABASE OF STUDENTS

/*PROGRAM TO WRITE DATABASE OF STUDENTS*/
#include<stdio.h>
#include<conio.h>
void main()
{
struct student
{
char name[20];
int roll_no;
int year;
}s[5];
int i,yr,rno,count=0;
char ch;
clrscr();
printf(“Give details of each student:\n”);
for(i=0;i<5;i++)
{
printf(“Enter the details of %d student:\n”,i);
printf(“NAME: “);
scanf(“%s”,&s[i].name);
printf(“ROLL NO.: “);
scanf(“%d”,&s[i].roll_no);
printf(“YEAR OF ADMISSION: “);
scanf(“%d”,&s[i].year);
}
printf(“Enter roll no and year of the student respectively to search a record: “);
scanf(“%d%d”,&rno,&yr);
for(i=0;i<5;i++)
{
if(yr==s[i].year && rno==s[i].roll_no)
{
printf(“NAME: %s\n”,s[i].name);
printf(“ROLL NO: %d\n”,s[i].roll_no);
printf(“YEAR: %d\n”,s[i].year);
}
else
count++;
}
if(count==5)
printf(“Record not found”);
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *