Answer to Question #330965 in C for NAS17

Question #330965

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.


1
Expert's answer
2022-04-19T12:02:05-0400
// 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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS