Write a program that takes marks of 10 students as input. It calculates the class average and displays it on the screen. Interaction with the program might look like this. Use while loop.
// Use while loop
#include <stdio.h>
int main()
{
int i, mark, sum;
float avg;
printf("Enter marks of 10 students:\n");
avg = 0;
i = 0;
while (i < 10)
{
printf("Student %d. Enter mark: ", i+1);
scanf("%d", &mark);
avg = avg + (double)mark;
i++;
}
printf("Average: %.1f\n", avg/10);
return 0;
}
Comments
Leave a comment