I just started learning C and prior to that I have no knowledge of programming.
So I am trying to run this one stat program, that will read input and give you mean, variance and etc. I used terminal to run the program. I pretty much copied the code from the book I am using.
There was no error when I ran the code but when I enter the input, it didn't do anything. The code is below.
#include <stdio.h>
#include <math.h>
int main()
{
    float x, max, min, sum, mean, sum_of_squares, variance;
    int count;
    printf("Enter data: "); /* not included in the original code*/
    if( scanf("%f", &x) == EOF )
        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)
                max = x;
            if ( x < min)
                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));
    }
}
 
    