Program for illustration Standard Deviation


#include<iostream.h>
#include<math.h>
#define MAX 5
#include<conio.h>
void main( )
{
float mean=0,variance=0;
int i,x[MAX];
clrscr();
for(i=0;i<MAX;i++)
{
         cout<<"\n Enter array elements: ";
         cin>>x[i] ;
         mean = mean+x[i];
}
mean = mean/MAX;
cout<<"\n Mean : "<<mean ;
for(i=0;i<MAX;i++)
       variance = variance + (x[i]-mean)*(x[i]-mean);
variance = variance/MAX;
cout<<"\nVariance : "<<variance ;
cout<<"\n Standard Deviation : "<<sqrt(variance);
}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|