Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

#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; }

image text in transcribedhow 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

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_2

Step: 3

blur-text-image_3

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

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions