C Program to Calculate Sum of Marks to Demonstrate Structures

include

struct student
{
char name[10];
int rollno;
int subject[5],total;
};
main ( )
{
static struct student s[100];
int n,i,j;
//clrscr();
printf(“Enter the number of Students: “);
scanf(“%d”,&n);
printf(“Enter the Marks of Five Subjects: “);
for(i=0; i<n; i++)
{
printf(“\nEnter student[%d] student marks”,i);
s[i].total=0;
for(j=0; j<5; j++)
{
scanf(“%d”,&s[i].subject[j]);
s[i].total=s[i].total+s[i].subject[j];
}
printf(“%d\n”,s[i].total);
}
}
OUTPUT:
Enter the number of Students: 2
Enter the Marks of Five Subjects:
Enter student[0] student marks 95 95 95 95 95
475

Enter student[1] student marks96 96 96 96 96
480

Leave a Reply

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