C Program to find average of 5 subjects


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


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


Example: How to find average of 5 subjects in C

Run it Now
#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("\nThe 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