# C program to find average of n numbers

list of c programs used for calculating average of numbers:  c program to find average of n numbers using functions, c program to find average of n numbers using for loop and  c program to find average of n numbers using while loop.

let see how to calculate average of n numbers.

average of 5 numbers 2,4,8,6,5 is
sum of all 5 digits/5    => ( 2+4+8+6+5)/5=25/5=5
5  is average of 5 no’s given above. C program to find average of n numbers using functions for while loop

## write a C program to find average of n numbers using functions

write a C program find average of n numbers using functions

#include<stdio.h>
main()
{
int n,A;
printf(“How many numbers(n) you going to enter:”);
scanf(“%d”,&n);
printf(“\n Enter the numbers:”);
for(i=0;i<n;i++)
{
scanf(“%d”,&A[i]);
}
find_Average(A)
}

void find_Average(int m)
{
int i,a,n=0,s=0;
while(m[i]!=’\0′)
n++;
for(i=0;i<n;i++)
{
s=s+m[i];
}
a=s/n;
printf(“\n The average of n numbers is %d”, a);
}

## write a C program to find average of n numbers using for loop

write a c program to calculate average of n numbers using for loop

#include<stdio.h>
main()
{
int n,m,i,a,s=0;
printf(“How many numbers(n) you going to enter:”);
scanf(“%d”,&n);
printf(“\n Enter the numbers:”);
for(i=1;i<=n;i++)
{
scanf(“%d”,&m[i]);
s=s+m[i];
}
a=s/n;
printf(“\n The average of n numbers is %d”, a);
}

OUTPUT:

How many numbers(n) you going to enter:5

Enter the numbers: 2 5 10 5 13

The average of n numbers is 7

## write a C program to calculate average of n numbers using while loop

write a C program to find average of n numbers using while loop

#include<stdio.h>
main()
{
int n,m,i,a,s=0;
printf(“How many numbers(n) you going to enter:”);
scanf(“%d”,&n);
printf(“\n Enter the numbers:”);
for(i=1;i<=n;i++)
{
scanf(“%d”,&m[i]);
s=s+m[i];
}
a=s/n;
printf(“\n The average of n numbers is %d”, a);
}

OUTPUT:

How many numbers(n) you going to enter:5
Enter the numbers: 2 5 10 5 13
The average of n numbers is 7