Computer Science, asked by vaibhavsharma7774, 19 days ago

Write a program to calculate average marks of n students, where n is entered by the user. ​

Answers

Answered by vvvvvedAnt
0

Explanation:

hope it was helpful

if not then give a feedback I'll remove this

Attachments:
Answered by guruu99
0

Answer:

#include <stdio.h>

int main()

{

int n,i;

float marks,sum=0,avg;

printf("Enter the number of students: ");

scanf("%d", &n);

for (i=1; i<=n; i++)

{

printf("Enter marks obtained by student %d: ", i);

scanf("%f", &marks);

sum+=marks;

}

avg=sum/n;

printf("Average marks = %.2f", avg);

return 0;

}

The above program is used to calculate the average marks of n students, where n is entered by the user. The program starts by declaring two integer variables, i and n and two float variables, marks and sum. The printf statement is used to ask the user to enter the number of students for which average marks need to be calculated. The for loop is used to ask the user to enter the marks obtained by each student. The marks entered by the user are stored in the marks variable. The sum of all the marks entered is stored in the sum variable. The average of all the marks is calculated by dividing the sum with the total number of students and stored in the avg variable. The printf statement is used to print the average of marks obtained by the students. Finally, the return statement is used to return 0 to the main function.

To know more about C programming language

https://brainly.in/question/4028873

For more questions related to

C programming language

https://brainly.in/question/27835773

#SPJ3

Similar questions