Prints the mean and standard deviation mean sum

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: y of data and * displays the difference between each value and the mean. */ #include <stdio.h> #include <math.h> #define MAX_ITEM 8 /* maximum number of items in list of data */ int main(void) { double x[MAX_ITEM], mean, st_dev, sum, sum_sqr; int i; /* /* /* /* /* data list */ mean (average) of the data */ standard deviation of the data sum of the data */ sum of the squares of the data */ */ /* Gets the data */ printf("Enter %d numbers separated by blanks\n> ", MAX_ITEM); for (i = 0; i < MAX_ITEM; ++i) scanf("%lf", &x[i]); conPnued… 18 /* Computes the sum and the sum of the squares of all data */ sum = 0; sum_sqr = 0; for (i = 0; i <= MAX_ITEM; ++i) { sum += x[i]; sum_sqr += x[i] * x[i]; } /* Computes and prints the mean and standard deviation */ mean = sum / MAX_ITEM; st_dev=sqrt((MAX_ITEM * sum_sqr - sum * sum)/ (MAX_ITEM*MAX_ITEM)); printf(&quo...
View Full Document

Ask a homework question - tutors are online