Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a second version of the median program ( median 2 . cc ) which repeatedly asks the user to enter a positive number, and

Write a second version of the median program (median2.cc) which repeatedly asks
the user to enter a positive number, and displays the median of the list of numbers
entered so far. You should start with an array of size 0 and increase the size of the
array each time a new number is entered. Exit the program when the user entered an
integer which is negative or 0. You should write the function:
int *resize(int *A, int n);
which increases the size of an array of n elements to n+1 elements. The first n elements
should be copied to the new array. The pointer to the array is returned, and the
original array passed into resize is deleted. An array of size 0 should be represented
by the nullptr pointer.
Sample session:
Enter a positive integer (<1 to quit): 6
The median so far is 6.
Enter a positive integer (<1 to quit): 10
The median so far is 8.
Enter a positive integer (<1 to quit): 3
The median so far is 6.
Enter a positive integer (<1 to quit): 7
The median so far is 6.5.
Enter a positive integer (<1 to quit): 9
The median so far is 7.
Enter a positive integer (<1 to quit): 2
2
The median so far is 6.5.
Enter a positive integer (<1 to quit): 10
The median so far is 7.
Enter a positive integer (<1 to quit): 0

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

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

What are the objectives of Human resource planning ?

Answered: 1 week ago

Question

Explain the process of Human Resource Planning.

Answered: 1 week ago