22. C Program to Read Marks of 3 Subjects and Display the Total, Avg.
How does this program work?
- In this program you are going to learn about How to find Sum of 3subjects and their average using C language.
- Take User inputs for Marks of 3subjects and store them in 3different variables.
- find out the total and averages values and display using C language.
Here is the code
#include <stdio.h>
int main(void)
{
int total, eng, maths, science;
float average;
printf("Enter the values of 3subjects english , maths, science \n");
scanf("%d %d %d", &eng, &maths, &science);
// Compute total marks
total =(eng + maths + science);
//Compute the average of total marks
average=total/3;
printf("Total of the 3subjects= %d \n", total);
printf("Average of the 3subjects = %f \n", average);
return 0;
}