Question: Dynamic array In this task, you are required to use dynamic memory management functions to implement two functions. 1. Implement a function that allocates an

 Dynamic array In this task, you are required to use dynamic

Dynamic array In this task, you are required to use dynamic memory management functions to implement two functions. 1. Implement a function that allocates an int array of n elements, and fills the array with integers it reads from the command line (standard input stream). i. The complete function declaration is int *create_dyn_array (unsigned int n); n is the number of elements in the array. ii. The function reads maximum of n integers using scanf function. Hint Do not forget to check the return value of scanf function call. iii. After reading n integers, the function returns a pointer to the dynamically allocated memory. 2. Implement a function that appends a new element to the existing dynamically allocated int array. i. The complete function declaration is int *add_dyn_array(int *arr, unsigned int num, int newval); - arr is the dynamically allocated array. - num is the number of elements in arr. is the value of the new element that will be appended to arr. ii. After setting the value of the new element, the function should return a pointer to the resized array

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!