Question: Please help with the following problem using Visual Studio (using namespace std) as i am not familiar with any other compilers. Thank you. Write a
Please help with the following problem using Visual Studio (using namespace std) as i am not familiar with any other compilers. Thank you.
Write a function int* read_data(int& size) that reads data from cin until the user ter minates 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.
Test Cases: 1. Please use 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 (10). Note: Please print the input stream 2. Then, you enter another 5 numbers as following 1.5 4.5 9.5 16.5 7.5 11.5 Note: Please print the members of your final array(n). 3. You should use the Dynamic Memory Allocation (DMA) technique to implement this exercise.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
