Answered step by step
Verified Expert Solution
Link Copied!

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++
image text in transcribed
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

More Books

Students also viewed these Databases questions

Question

6. Identify characteristics of whiteness.

Answered: 1 week ago

Question

9. Explain the relationship between identity and communication.

Answered: 1 week ago