Question: C++ code... kindly read the statement carefully and attempt accordingly under given restrictions. Also add some comments to explain a bit please! TASK 3: Write

C++ code... kindly read the statement carefully and attempt accordingly under given restrictions.
Also add some comments to explain a bit please!
TASK 3: Write a program that keeps taking integer input from the user until user enters -1 and displays the data in reverse order. Your program should save the input in a dynamically allocated array. Initially create a dynamic array of five integers. Each time the array gets filled your program should double the size of array (i.e. create a new array of double size, copy previous data in new array, delete previous array) and continue taking the input. After receiving -1 (ie, end of data input) your program should print the numbers in the reverse order as entered by the user. Important Note: subscript operator [] is not allowed to traverse the array. Use only offset notation. i.e instead of using myArray[i] use *(myArray+i) to read/write an element. Do not consume extra space. There shouldn't be any memory leakage or dangling pointers in your code. You have to make use of the following functions for this task: void Input (int * & iarr, int & size); // why is size passed by reference for this? void reverse (int * iarr, int size); void Output (int * iarr, int size)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
