Write a program to display the details of 5 students using structure

//this is a program to display the details of 5 students
#include<stdio.h>
#include<conio.h>
void main()
{
struct student
{
char name[20];
int rollno;
float per;
};

struct student s[5];

int i;

printf("\n\nAccepting the details: ");
for(i=0;i<5;i++)
{
printf("\n\nEnter the Name, Roll No. and Percentage of student %d: ",i+1);
scanf("%s%d%f",s[i].name,&s[i].rollno,&s[i].per);
}

printf("\n\nDisplaying the Details: ");

for(i=0;i<5;i++)
{
printf("\n\nDetails of Student %d",i+1);
printf("\n\nName=%s\n\nRoll No.=%d\n\nPercentage=%f",s[i].name,s[i].rollno,s[i].per);
}

getch();
}


Previous
Next Post »