Question: C++ 1. Write the function sum() that receives two parameters; a double type array and an integer type parameter representing the size of the array.

C++

1. Write the function sum() that receives two parameters; a double type array and an integer type parameter representing the size of the array. The function returns the sum of the elements in the array.

2. Write the function average() that receives two parameters; a double type array and an integer type parameter representing the size of the array. This function calculates the average of the numbers in the array and returns this average. The function average() must make a call to the function sum() in part (a) to obtain the sum of the elements used in calculating the average.

3. Write a main function that initializes and array of double type using random integers between 1 and 100. You can decide on the size of the array, perhaps a size between 10 to 20 elements. Display the numbers generated then call the function average() to receive the value of the average, which is then printed.

4 Rewrite the function average in part (b) average2() but make the return type of the function asvoid and use a reference parameter to communicate/return the calculated average to the man() function. ( hint: instead of two parameters the function average2() must have three parameters with some minor adjustments) [no need to make a call to this function, just write it to demonstrate the use of reference parameters.]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!