How to write a C Program To Store Students Record Using Structure in C Programming Language ?
Solution For C Program :
/*C Program To Store Students Record Using Structure.*/
#include<stdio.h>
#include<conio.h>
struct student{
int role_no;
char name[20];
int marks;
char course[20];
};
struct student stud[10];
void main()
{
int i;
clrscr();
printf("enter the students record one by one.\n");
for(i=0;i<3;i++)
{
printf("Enter the role no= ");
scanf("%d",&stud[i].role_no);
printf("Enter the name of student: ");
scanf("%s",&stud[i].name);
printf("Enter the marks obtained= ");
scanf("%d",&stud[i].marks);
printf("Enter the course: ");
scanf("%s",&stud[i].course);
}
clrscr();
printf("---------STUDENTS RECORD FILE-------\n");
for(i=0;i<3;i++)
{
printf("\nROLE NO.: %d",stud[i].role_no);
printf("\nNAME: %s",stud[i].name);
printf("\nCOURSE: %s",stud[i].course);
printf("\nMARKS OBTAINED: %d",stud[i].marks);
printf("\n----------------------------------\n\n");
}
getch();
}
You may also learn these C Program/Code :