Question: a. Create a function called resize that can be used to increase the size of integer arrays dynamically. The function takes three parameters. The first

a. Create a function called resize that can be used to increase the size of integer arrays dynamically. The function takes three parameters. The first parameter is the original array, the second parameter is the size of this array, and the third parameter is the size of the larger array to be created by this function. Make sure that you allocate memory from the heap inside this function. After allocating memory for the second array the function must copy the elements from the first array into the larger array. Finally, the function must return a pointer to the new array.

b. In main, allocate an array on the heap that is just large enough to store the integers 5, 7, 3, and 1.

c. Resize the array to store 10 integers by calling the resize function created in step a. Remove the old (smaller) array from the heap. Add the numbers 4, 2, and 8 to the end of the new array.

d. Write a sort function that sorts any integer array in increasing order.

e. Use the sort function to sort the array of numbers in c above. Display the sorted numbers.

Step by Step Solution

3.38 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets tackle the question step by step a Create a function called resize You need a function that dynamically allocates a larger memory space for an ar... View full answer

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 Programming Questions!