Question: 8. The following code needs a function called stats (). The function takes a pointer to an array of integers and returns the average
8. The following code needs a function called stats (). The function takes a pointer to an array of integers and returns the average value of the numbers in the array. In addition, a side effect of the function is that the values array_max and array_min will contain the largest and smallest value in the array after the stats function is called. You must write the stats () function, including the arguments that are passed to the function. Other than how the stats () function is called no other changes to main () are permitted. No global variables are permitted. // assume this file is called my_prog.c, and you make an executable file // called my_prog. It is run using ./my_prog 1000 #include #include int main(int arge, char *argv[]) { } int *array; int array_max, array_min, array_size; double array_average; int j; array_size=atoi (argv[1]); array = (int *) malloc( array_size*sizeof (int)); // fill the array with random numbers for(j=0; j < array_size; j++) array[j] = array_size* drand48 (); array_average stats ( printf("Avg=8&g, Max-&d, Min=%d ", = free (array); return 0; // you must fill in details here array_average, array_max, array_min);
Step by Step Solution
3.46 Rating (153 Votes )
There are 3 Steps involved in it
The screenshot shows a partial C code for a program that is intended to calculate some statistics of ... View full answer
Get step-by-step solutions from verified subject matter experts
