C programming

C program to find the arithmetic mean of n numbers using function.


#include<stdio.h>
void mean(float k, int b[50], float m);
//function declaration
void main()
{
int i, a[50];
float p, n;
printf("\n How many number you want to enter");
scanf("%f",&n);
printf("\nEnter %f numbers",n);
for(i=0; i<n; i++)
{
scanf("%d",&a[i]);
}
mean(n,a,p); //function call
getch();
}
 void mean(float k,int b[50],float m)
{
 int j,sum=0;
for(j=0; j<k; j++)
{
sum=sum+b[j];
}
m=sum/k;
printf("\n Arithmetic mean is =%f",m);
}
OUTPUT

Post a Comment

0 Comments