/* Program to compute max and average of an array */ #include #define SIZE 8 void read_array (double list[], int n); double get_max (const double list[], int n); double get_average (const double list[], int n); int main() { double array[SIZE]; read_array(array, SIZE); double max = get_max(array, SIZE); double ave = get_average(array, SIZE); printf("\nmax = %.2f, average = %.2f\n", max, ave); return 0; } /* function to read an array of n elements */ void read_array (double list[], int n) { int i; printf("Enter %d real numbers\n", n); printf("Separated by spaces or newlines\n"); printf("\n>"); for (i = 0; i < n; ++i) scanf("%lf", &list[i]); } /* Returns the max in an array of n elements */ double get_max(const double list[], int n) { int i; double max = list[0]; for (i=1; i max) max = list[i]; return max; } /* Returns the average of n array elements */ double get_average(const double list[], int n) { int i; double sum = 0; for (i=0; i