To find and print mean and mean deviation.
The Big Short: Inside the Doomsday Machinewrite a program in C to input 15 observations and then find and print mean and mean deviation from mean where, mean = SX/15 and mean deviation from mean = S |X-mean| / 15.
#include< #include< #include< void main( ) { int a, x[15]; float tot=0, mdt=0, d, m, md; printf("Input 15 values of x, one at a time\n"); for(a=0; a<15; a++) { scanf("%d", &x[a]); tot = tot+x[a]; } m = tot / 15; for(a=0; a<15; a++) { d = x[a] - m; if (d < 0 ) d = -d; mdt = mdt + d; } md = mdt / 15; printf("\n Mean = %f\n", m); printf("Mean deviation = %f\n", md); } |
---|
0 comments:
Post a Comment