Question: Write a program that allows the user to enter 2 integer vectors, then merges them into one vector, alternating elements from each vector. If one
Write a program that allows the user to enter 2 integer vectors, then merges them into one vector, alternating elements from each vector. If one vector is shorter than the other, alternate as long as you can, then append the remaining elements from the longer vector.
For example, if A is 1 4 9 16 and B is 9 7 4 9 11, then the result is 1 9 4 7 9 4 16 9 11.
The program should satisfy the following requirements:
The program should ask for the sizes of the 2 vectors (max 10).
The program should have a function in which the user will enter the data.
The program should have a function that displays a vector of a given size. Each vector the user enters will be displayed
The program should have a function that merges two vectors. The merge function should take pointers to both vectors and the resulting vector as arguments, as well as the size of the two initial vectors.
The program should display the merged vector.
You must use pointers to access the individual elements of the vector.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
