Question: Write a function that returns the double average value of a one-dimensional integer array, in addition to determining the number of values in the array
Write a function that returns the double average value of a one-dimensional integer array, in addition to determining the number of values in the array that are greater than the average. Assume that the corresponding function prototype statement is the following:
void average (int x[], int npts, double *average, int * gtr);
where npts contains the number of values in array x, gtr is a pointer to the variable in which to store the number of values in array x that are greater than the average.
ALGORITHM DEVELOPMENT - Pseudocode:
/*-------------------------------------------------------------*/
main
print the array, the average, greater.
/*-------------------------------------------------------------*/
void average (int x[], int npts, double *average, int * gtr)
initialize appropriate values to zero
for loop starting at zero through npts
sum the numbers
compute the average
for loop from zero through npts
find number of values greater than average
return
/*-------------------------------------------------------------*/
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
