C Program to find the average of 5 subjects


In this program, You will learn how to find an average of 5 subjects in c.


(2 + 3 + 4 + 5 + 6) / 5 = 4.000000

Example: How to find the average of 5 subjects in c.

#include<stdio.h>

int main() {

   float a, b, c, d, e, s, avg;

   printf("Enter 5 Subjects Marks :");
   scanf("%f%f%f%f%f", &a, &b, &c, &d, &e);

   s = a + b + c + d + e;

   avg = s / 5;

   printf("The Sum is :%f", s);
   printf("\nThe Average is :%f", avg);

   return 0;
}

Output:

Enter 5 Subjects Marks :2 3 4 5 6
The Sum is :20.000000
The Average is :4.000000