Get Email Subscription

Enter your email address:

Delivered by FeedBurner

Saturday, April 3, 2010

To find and print mean and standard deviation.

Write a program in C to input 5 integer values (x) and to find and print their mean (m) and standard deviation (sd).

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main( )
{
int i, x[5];
float s1=0, s2=0, d, m, sd;
clrscr( );
printf("Input 5 values of x, one at a time\n");
for(i=1; i<=5; i++)

{
scanf("%d", &x[i]); 
s1 = s1+x[i]; 

m = s1/5;
for(i=1; i<=5; i++)
{
d = s[i] - m;
s2 = s2+d*d;
}
sd = sqrt(s2/5);
printf("\n The mean is %f\n", m);
printf("The standard deviation is %f\n", sd);
}

Related Posts by Categories



0 comments:

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP