C program using Structure for storing Student details

It’s the C program using Structure for storing Student details. The user asked to enter student details,  then program stores students details using structure, and display student details on the screen.

To understand this program, it’s better you should know the following topics:

Program (1): to store student details using Structure.

#include<stdio.h>
#include<conio.h>
void main()
{
struct stud  //structure initialization
{
int rollno;
char name[20];
int p,c,m;
};
struct stud s[3];// structure variable declaration
int j;
for(j=0;j<3;j++)   //accepting values in structure
{
printf("Enter ro11no, Name, and Marks of Physics, Chemistry,and Maths of %d Student : ",j+1);
scanf("%d %s %d %d %d",&s[j].rollno,&s[j].name,&s[j].p,&s[j].c,&s[j].m);
}
for(j=0;j<3;j++)
{
printf("\n %d %s %d %d %d",s[j].rollno,s[j].name,s[j].p,s[j].c,s[j].m);
}
getch();
}

Output (1)

Enter ro11no, Name, and Marks of Physics, Chemistry,and Maths of 1 Student : 1
john
56
44
58
Enter ro11no, Name, and Marks of Physics, Chemistry,and Maths of 2 Student : 2
rita
43
78
65
Enter ro11no, Name, and Marks of Physics, Chemistry,and Maths of 3 Student : 3
vansh
46
98
66

1 john 56 44 58
2 rita 43 78 65
3 vansh 46 98 66

Published by

Electrical Workbook

We provide tutoring in Electrical Engineering.

Leave a Reply

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