Question: Hello, I have tried to code this exercise but I cannot find a way to do it so I am having trouble to do this
Hello, I have tried to code this exercise but I cannot find a way to do it so I am having trouble to do this exercise.
Prompt: 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.
Please finish P7.10 on page 344. Book: C++ for everyone by Cay Hortsman Requirements: 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 echo (print) the input stream. Do not prompt the user for the size of the array. Your program can and should declare the size of the array is 10 initially. 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. 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
Get step-by-step solutions from verified subject matter experts
