Question: C++ (increase array size) Once an array is created, it's size is fixed. Sometimes, you need to add more values to an array than it

Once an array is created, its size is fixed. Sometimes, you need to add more values to an array than it is able to hold; in this case, you may create a new larger array to replace the existing array. Write a function that returns a pointer to a new int array that is double the size of the array passed in the parameters to this function. Use the following header: int double capacity (const int *list, int size) Write a test program that prompts the user to enter the number of elements of an array, and then enter the elements (type int). After that the program will use your double capacity() function to double the capacity of the array and prompt the user for more values. Finally, the program will display all the elements of the array. Note: make sure to delete the old array, since it isn't likely to be used after the function creates and returns the new, bigger array. SAMPLE RUN #1: ./double_capacity Interactive Session Show Invisibles Enter the number of elements for the array:5 Enter 5 int values:0 1 2 3 4 Enter 5 more int values: 5 6 7 8 9 The elements of the array are: 0 1 2 3 4 5 6 7 8 9 Highlight: None
Step by Step Solution
3.38 Rating (154 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
