Question: Please Code in C #include #include const int MAX = 10000; /** * Do not modify main. Create the functions sum, average, min and max
Please Code in C
#include
const int MAX = 10000;
/** * Do not modify main. Create the functions sum, average, min and max to * complete this program. Use the testdata file to test it. * For each function the first parameter is an array of integers and the second * is the number of integers in the array (i.e. valid indexes would be 0 through * n-1.) * * Example input/output: * ./p1 < test/num-data * Total = 30 * Sum = 72086204 * Average = 2402873.50 * Min/max = -83444595/71865584 */
int main(int argc, char *argv[]) { char line[MAX]; int nums[MAX], n = 0;
while(fgets(line, MAX, stdin) != NULL) nums[n++] = atoi(line);
printf("Total = %d ", n); printf("Sum = %d ", sum(nums, n)); printf("Average = %.2f ", average(nums, n)); printf("Min/max = %d/%d ", min(nums,n), max(nums, n));
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
