Question: #include using namespace std; double* arr = new double[10]; double* read_data(int& size) { int count = 0; float value; if (size >= 10) { double*

 #include using namespace std; double* arr = new double[10]; double* read_data(int&

#include

using namespace std;

double* arr = new double[10];

double* read_data(int& size) { int count = 0; float value; if (size >= 10) { double* new_array = new double[2 * size]; for (int i = 0; i > value) { arr[size] = value; size++; } cin.clear(); cin.ignore(); return arr; }

int main() { float value; char repeat; do { int size = 0; read_data(size); cout > repeat; } while (repeat == 'y');

cout

system("Pause"); return 0; }

size) { int count = 0; float value; if (size >= 10)how to fix the error the array should be 16

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 won't 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. Requirements: 1. Your program should prompt the user for the following sequence of numbers 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.54.59.516.57.511.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. 1. 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!