In this program we are going to implement a structure called student_record. It contains member variables as student name, branch name, total marks.
To learn about structure and union from beginning Click Here.
Example :
#include<stdio.h>
#include<conio.h>
//Declaration of structure student_record
struct student_record{
//Member variables of student_record
char student_name[30],branch_name[30];
int total_marks;
}student[10];
void main()
{
int i,n;
clrscr();
//Number of students to include
printf("\nEnter the number of students you want to include:");
scanf("%d",&n);
//Student information
printf("\nEnter the following information related to students");
for(i=0;i<n;i++)
{
printf("\nStudent %d Name:",i+1);
scanf("%s",&student[i].student_name);
printf("\nBranch Name:");
scanf("%s",&student[i].branch_name);
printf("\nTotal Marks:");
scanf("%d",&student[i].total_marks);
}
//Printing student information on output window
printf("\nEntered Information:");
printf("\n|| S.No. || Student Name || Branch Name || Total Marks ||");
for(i=0;i<n;i++)
printf("\n|| %d || %s || %s || %d ||",i+1,student[i].student_name,student[i].branch_name,student[i].total_marks);
getch();
} |
Output :
For More GTU C Programming Lab Experiments Click Here