Question: Please do this in C++. Write a function called splice () that splices two integer arrays together by first allocating memory for a dynamic array

Please do this in C++.

Write a function called splice() that splices two integer arrays together by first allocating memory for a dynamic array with enough room for both integer arrays, and then copying the elements of both arrays to the new array as follows:

first, copy the elements of the first array up to a given position,

then, copy all the elements of the second array,

then, copy the remaining elements in the first array.

The function should have parameters for the two input arrays, their lengths, and the number of elements of the first array to be copied before the second is spliced. The function should return a pointer to the new array.

To test the function, write a program that:

Prompts the user for the sizes of the two integer arrays and the number of

elements of the first array to be copied before the splice (e.g., 32 means insert

32 elements of the first array and then the second array),

Creates the two arrays and fills them with random values. Use the seed 100 for

srand().

Outputs the contents of the two input arrays in rows with 10 values/row.

Outputs the contents of the spliced array in rows with 10 values/row.

The program should use dynamic memory to store all three arrays. Be sure to de-allocate the memory before exiting. Your program should run and terminate with no run-time errors.

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!