Correct following program.
Calculate the average value while reading a list of integer values in a file, and then print a number of values that are greater than the average.
#include <stdio.h> #define MAXSIZE 128 int main(void) { int data[MAXSIZE]; int size, sum, count, i; double avg; sum = 0; size = 0; while (scan("%d", data[size]) != EOF) { sum += data[size]; size++; } avg = (double) sum / size; printf("avg = %f\n", avg); for (i = 1; i <= size; i++) { if (data[i] > avg) { count++; } } printf("greater than avg: %d\n", count); return 0; }