CSIS 112: Lab 6—Splice Arrays

$30.00

Download Details:

  • Name: Lab-6-kugsod.zip
  • Type: zip
  • Size: 110.79 KB

Category:

Description

5/5 - (1 vote)

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 must ensure that non-numeric and negative entries are not entered.  Use modular design in your program.  That is, separate functions should be used to fill the arrays with random numbers, print the arrays, and of course, splice the arrays together.

 

 

Deliverables:

  • Complete the programming assignment described above and submit your completed assignment in accordance with the lab submission policies.