Question: C++ PROGRAMMING A) In this first task, you will write several functions that work with integer arrays. In your program, start by prompting the user

C++ PROGRAMMING

A) In this first task, you will write several functions that work with integer arrays. In your program, start by prompting the user for the amount of numbers you want to work with. Given that input, dynamically allocate an array of that size. Then fill the array by calling the function initialize_array. Initialize_array should fill the array with random numbers in the range of 1-100. After initialization, display the array and then call a function that creates a NEW array by sorting the current one. This is the function sort_array given below. Note that this does something in addition to the functions in the book, in that I want your function to create a NEW ARRAY that is sorted from the old array. So, after this function call, you will have a second array with the numbers sorted. Display the contents of both arrays after the function call, with appropriate labeling so the user can tell which is the initial array and which is the output array.

Required functions: void initialize_array(int[], int); int * sort_array(int [], int); void print_array(int[], int);

B) In this task you will write a function that takes in an array and creates two smaller arrays from it. This function, once given its array, should randomly pick a location and split the array up, creating two arrays. One array should hold all the elements before that element, another array holding all elements after that element. This function should then display the pivot element that is no longer in either of the child arrays. Display the original array before making your function call to split the arrays, then display all 3 arrays afterwards. You should use as input to split_up_array the sorted array from the previous part.

Required functions: void split_up_array(int [], int, int *&, int *&,int &, int &); void print_array(int[], int);

C) In this part you will write a function that takes in two arrays that could be of different sizes. The function will then create a new array that will store in each position of it, the sum of the values in both of the other arrays. Note that if an array no longer has an element at that position, then its value should be 0 in this sum. Display the two arrays before the function call, after the function call and also display the calculated array in the main body. You should use as input to calc_sum the two arrays created by split_up_array in the previous examples.

Required functions: int calc_sum(int *, int, int *, int, int *&, int &); void print_array(int[],int);

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!