#include <stdio.h>
#include <math.h>
main()
{
float x,/*current value input*/
max,
min,
sum,
mean,
sum_of_squares,
variance;
int count;
if (scanf("%f", &x) == EOF ) /* EMPTY? */
printf( "0 data items read\n");
else {
max = min = sum = x;
count = 1;
sum_of_squares =x * x;
while (scanf("%f", &x) != EOF)
{
count += 1;
if (x > max) /*new high?*/
max = x;
if (x < min) /* new low?*/
min = x;
sum += x;
sum_of_squares += x * x;
}
printf( "%d data items read\n", count);
printf("maximum value read = %f\n", max);
printf("minimum value read = %f\n", min);
printf( "sum of all values read = %f\n", sum);
mean = sum / count;
printf ("Mean = %f\n", mean);
variance = sum_of_squares / count - mean * mean;
printf("variance = %f\n", variance );
printf( "standard deviation = %f\n",
sqrt (variance));
}
}
I'm showing the whole program since I can't trace where the problem is.