Calculate Marks for Many Students in C program

How to write a c program to calculate marks for many students in c programming ?



Solution:
#include <stdio.h>

int main()
{
int sum[100];
int studentNo, subjectNo, i, j, marks;

printf("How many students?\n");
scanf("%d", &studentNo);
printf("How many subjects?\n");
scanf("%d", &subjectNo);

for(i = 0; i < studentNo; i++)
{
sum[i] = 0;
for(j = 1; j <= subjectNo; j++)
{
printf("Enter marks for subject %d of student %d: ", j, i+1);
scanf("%d", &marks);
sum[i] += marks;
}
printf("\n");
}

for(i = 0; i < studentNo; i++)
printf("Marks of student %d: %d\n", i+1, sum[i]);

return 0;
}


Learn More :