## Pages

### C Program Average,Mean,Sum of Array

This C Programs Finds the Average, Sum and Mean Deviation of Elements of Array. This is a part of Mumbai University MCA Colleges C Programs MCA Sem 1

#include<stdio.h>
#include<conio.h>
#include<math.h>
int arrsum(int *,int);
float average(int,int);
float deviation(int *,float,int);
void main()
{
int a,n,i,sum;
float avg,mean;
clrscr();
printf("Enter number of elements of an array (upto 10)\n");
scanf("%d",&n);
printf("Enter elements of an array\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
sum=arrsum(a,n);
avg=average(sum,n);
mean=deviation(a,avg,n);
printf("Sum = %d\nAverage = %f\nMean Deviation = %f\n",sum,avg,mean);
getch();
}
int arrsum(int *a,int n)
{
int i,s=0;
for(i=0;i<n;i++)
{
s+=*(a+i);
}
return s;
}
float average(int s,int n)
{
float avg=0.0;
avg=(float)s/n;
return avg;
}
float deviation(int *a,float avg,int n)
{
int i;
float s=0.0,dev=0.0;
for(i=0;i<n;i++)
{
s+=((*(a+i)-avg)*(*(a+i)-avg));
}
dev=sqrt(s/n);
return dev;
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.