Q:

Write a program to input from user (5 subjects) sum,average

0

Write a program to input from user (5 subjects) sum,average

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

#include<stdio.h>
#include<conio.h>
void main()
{
int marks,sub,count,sum=0;
float avg=0.0;
printf("Enter number of subjets\n");
scanf("%d",&sub);
printf("Enter %d Subjects marks\n",sub);
for(count=1;count<=sub;count++)
{
scanf("%d"&marks);
sum=sum+marks;
}
avg=sum/sub;
printf("sum=%d\nAverage =%0.2f\n",sum,avg);
}

Output:

Enter number of subject
5
Enter 5 Subject marks
80
74
87
86
78
sum=405
Average=81.00

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Programming Exercises With Solutions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a program to print student marksheet... >>
<< write program to generate following pattern...