GoogelAddUnit1

Thursday, 10 March 2011

C Program to find the Standard Deviation.

/*STANDERD DEVIATION*/     
                 
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,x[100],sum,i;
float mean,vsum,ksum,sd;
clrscr();
printf("Enter the n value\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&x[i]);
}
for(i=0;i<n;i++)
sum=sum+x[i];
mean=sum/n;
for(i=0;i<n;i++)
vsum=vsum+((x[i]-mean)*(x[i]-mean));
ksum=vsum/n;
sd=sqrt(ksum);
printf("%f",sd);
getch();
}

7 comments: