C Program to Find Average of Five Numbers

This program takes five numbers as input from the user, calculates their average, and displays the result. It demonstrates basic arithmetic and user input handling in C.

Concept Overview

The average of a set of numbers is the sum of all numbers divided by the total count. In this program, we use simple arithmetic operations and the `scanf()` and `printf()` functions to achieve this.

Program

// Code file not found: //C program to find average of 5 numbers.

#include <stdio.h>
int main()
{
  float n1, n2, n3, n4, n5;
  float avg;
  printf("Enter five numbers:");
  scanf("%f%f%f%f%f", &n1, &n2, &n3, &n4, &n5);
  avg = (n1 + n2 + n3 + n4 + n5) / (5.0);
  printf("Average of five numbers=%lf", avg);
  return 0;
}

Output

Enter five numbers: 10 20 30 40 50
Average of five numbers=30.000000

Explanation