Question
I need help with the following program in C programming. Resize Array An actual array cannot be resized. However, a dynamically allocated array could seem
I need help with the following program in C programming.
Resize Array
An actual array cannot be resized. However, a dynamically allocated array could seem to be resized by creating a new array and copying the elements from the original array into the new array. Your task is to write a function to "resize" an array of integers. Write a program to get an array size from the user and dynamically allocate an array of that size and fill it with random integers less than 100 and print the array. Then, get a new size from the user and use the resize function and print the array. Here's a function header to get you started:
void resize_array(int ** array, int size, int new_size)
Sample Runs:
Enter Size: 3
array (pointing to 0x7fd15fd00000):
array[0] = 37 array
[1] = 65
array[2] = 44
Enter New Size: 5
array (pointing to 0x7fd15fd00010):
array[0] = 37
array[1] = 65
array[2] = 44
array[3] = 0
array[4] = 0
Enter Size: 5
array (pointing to 0x7fe766500000):
array[0] = 84
array[1] = 53
array[2] = 25
array[3] = 92
array[4] = 51
Enter New Size: 3
array (pointing to 0x7fe766600000):
array[0] = 84
array[1] = 53
array[2] = 25
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started