Gabriel M.

asked • 10/20/21

Write a C++ program with the following:

  1. expandArr(arr,size) , a function which accepts an array parameter and expands the array by 50%. The function deallocates any old dynamic memory and returns the newly created array.i.e., newSize = oldSize * 1.5
  2. getMax, a function which accepts an array parameter and returns the largest element in the array
  3. getAvg, , a function which accepts an array parameter and returns the average of all elements.
  4. main, performs the following:
  5. Create a dynamic array of size 5 and type double
  6. Prompt the user to enter values into the array. The prompt should continue until a negative number is entered
  7. During the entry process, if the array is filled, expand the array by calling the expandArr() function
  8. Display the maximum value in the array by calling getMax()
  9. Display the average values in the array by calling getAvg()

Sample program execution:

Enter grade: 26

Enter grade: 99

Enter grade: 5

Enter grade: 0

Enter grade: 67

Enter grade: 79

Enter grade: 55

Enter grade: -1

Max: 99

Avg: 47.2857

Tom O.

tutor
This is not a simple question but a programming assignment I recommend we schedule a tutoring session. Do you have the actual prototype for the expand function? Not sure if the teacher wants you to STL arrays or C arrays?
Report

10/24/21

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.