Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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++
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started