Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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 Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions