C Average - Average program in c



 average in c

Learn C - C tutorial - average in c - C examples - C programs

C - Average

  • Average is a middle number of a list of numbers.
  • Average refers to the sum of the numbers divided by how many numbers, this would be called the average.
  • FOR EXAMPLE,
    a=25; b=25;
    a+b=25+25=50;
    Avg=50/2=25

Sample code

#include <stdio.h>
#define	N 10
int main()
{
    int	count ;
    float sum, average,number=24 ;
    sum = 0 ;
    count = 0 ;
    while( count < N )
    {
        sum = sum + number ;
        count = count + 1 ;
    }
    average = sum/N ;
    printf("N = %d\nSum = %f", N, sum);
    printf("\nAverage = %f", average);
}

Output

N = 10
Sum = 240.000000
Average = 24.000000


View More Quick Examples


Related Searches to C Average - Average program in c