Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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).

I need to make the first original array for the first 10 that will show the orginal array as an output and then I will have a new line that will ask to add another set of array that will combine with the old array making the second array be the new output.

ex: Please enter the integers: 1.3 4 5.2 16.3 9.99 7.21 4.5 7.43 11.21 12.5 q

// shows 10 arrays

output: the original array is: {1.3, 4, 5.2, 16.3, ...., 11.21, 12.5 }

//making the second new array and add with the old array

Please enter new integers: 1.5 4.5 9.5 16.5 7.5 11.5 Q

//shows the new array 16

New array is: {1.3, 4, 5.2, 16.3, ...., 11.21, 12.5, 1.5, 4.5, 9.5, 16.5, 7.5, 11.5}

I'm not sure if it makes sense or not.

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions