Question: In C++ Write a function int* read_data(int& size) that reads data from cin until the user terminates input by entering Q. The function should set

In C++

Write a function int* read_data(int& size) that reads data from cin until the user terminates input by entering Q. The function should set the size reference parameter to the number of numeric inputs. Return a pointer to an array on the heap. That array should have exactly size elements. Of course, you wont know at the outset how many elements the user will enter. Start with an array of 10 elements, and double the size whenever the array fills up. At the end, allocate an array of the correct size and copy all inputs into it. Be sure to delete any intermediate arrays.

In C++ Write a function int* read_data(int& size) that reads data from

1. Your program should prompt the user for the following sequence of numbers 1.3 4 5.2 16.3 9.99 7.21 4.5 7.43 11.21 12.5 to fill out an array of size 10. Note: Please print the input stream 2. Then, prompt the user for another 6 numbers as following 1.5 4.5 9.5 16.5 7.5 11.5 You need to create a new array of size 20 to contain all 16 numbers. Note: Please print all 16 members of your new array. 3. You should use the Dynamic Memory Allocation (DMA) technique to implement this exercise (See section 7.4 for more information)

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!