Question: 1. Write functions that return the following values. (Assume that a and n are parameters, where a is an array of int values and n
1. Write functions that return the following values. (Assume that a and n are parameters, where a is an array of int values and n is the length of the array.)
(a) The largest element in a.
(b) The average of all elements in a.
(c) The number of positive elements in a.
1. Write your program here:
9.4
2. The following (rather confusing) function finds the median of three numbers. Rewrite the function so that it has just one return statement.
double median(double x, double y, double z)
{
if (x <= y)
if (y <= z) return y;
else if (x <= z) return z;
else return x;
if (z <= y) return y;
if (x <= z) return x;
return z;
}
2. Write your program here:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
