Dynamic Array Class
Learn to create a dynamic array in C++ and perform operations on it.
We'll cover the following
Problem
Merging of arrays involves two steps; sorting the arrays that are to be merged, and adding the sorted elements of both the arrays to a new array in sorted order. Write a program that merges two arrays into a third array.
Sample run
Here’s what you should see when you run the program.
Enter elements for first array:
Enter the element no. 1 67
Enter the element no. 2 12
Enter the element no. 3 -4
Enter the element no. 4 43
Enter the element no. 5 2
Enter elements for second array:
Enter the element no. 1 8
Enter the element no. 2 10
Enter the element no. 3 -2
Enter the element no. 4 39
Enter the element no. 5 6
Enter the element no. 6 7
Enter the element no. 7 19
First array:
-4 2 12 43 67
Second array:
-2 6 7 8 10 19 39
After Merging:
-4 -2 2 6 7 8 10 12 19 39 43 67
Coding solution
Here is a solution to the problem above.
Get hands-on with 1400+ tech skills courses.