Question: C++ 2) Write a function called CalcAverage that takes as parameters an array of doubles and the array size as integer, and returns the average

C++
 C++ 2) Write a function called CalcAverage that takes as parameters

2) Write a function called CalcAverage that takes as parameters an array of doubles and the array size as integer, and returns the average of the array (of type double) Write a main program to test your function by reading the array from the user (1 to signal end of input). The program should output the array and the average. 3) a) Write a function called Count that takes as parameters an integer array al, and integer num, and returns the number of times num appears in the array a. You should assume that there is a -1 at the end of the array b) Use your function Count above to write a function called IsMember that takes as parameters an integer array s1 (assumed to be terminated by -1) and an integer x and returns true (i.e. 1) if x appears anywhere in the array. Write a main program to test the function Count using a user defined array 4) Use the function swap (shown on slide 47 on Functions-Revision, pass-by-reference) to write a void function called Reverse that takes as parameters an integer array al and the array size (as integer n) and reverses the array al so that its last element becomes first, its second-to-last becomes its second etc. (NOTE: This function alters the array al. You should not use any other array to store the reversed version) Write a main program to test your function by printing the array before the call to Reverse and after. (You need not use user defined array here. You can hard-code the input array in the main program using some initializers)

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!