Contact Learn C
Copy

Program 299: Program to Display Mean,Variance and Standard Deviation

Program 299: Program to Display Mean,Variance and Standard Deviation
 
#include<stdio.h>
#include<math.h>
main()
{
 int i,j,n;
 float mean,sum=0.0,sumMeanSquare=0.0,meanSquaredDifference,standardDeviation;
 printf("Enter number of terms\n");
 scanf("%d",&n);
 float a[n],subtractMeanSquare[n];
 printf("Enter Numbers\n");
 for(i=0;i<n;i++)
 {
  scanf("%f",&a[i]);
  sum+=a[i];
 }
 mean=(float)(sum/n);
 printf("Mean for given numbers is %f\n",mean);
 for(i=0;i<n;i++)
 {
  subtractMeanSquare[i]=(a[i]-mean)*(a[i]-mean);  
  sumMeanSquare+=subtractMeanSquare[i];
 }
 meanSquaredDifference=(float)(sumMeanSquare/n);
 standardDeviation=(float)(sqrt(meanSquaredDifference));
 printf("Variance =%f\n",meanSquaredDifference);
 printf("Sandard Deviation=%f\n",standardDeviation);
 
}
Explanation:

//Coming Soon...

Output:
Program to Display Mean,Variance and Standard Deviation

Donate

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide