Finding the common members of two dynamic arrays: Write a program that first reads two arrays and then finds their common members (intersection). The program should first read an integer for the size...



Finding the common members of two dynamic arrays: Write a program that first reads two arrays and then finds their common members (intersection). The program should first read an integer for the size of the array and then should create the two arrays dynamically (using new) and should read the numbers into array1 and array2 and then should find the common members and show it.



Note: The list of the common members should be unique. That is no member should be listed more than once.


Tip: A simple for loop is needed on one of the arrays (like array1) and one inner for loop for on array2. Then for each member of array1, if we find any matching member in array2, we record it.


Sample run:


           Enter the number of elements of array 1:  7


    Enter the elements of array 1: 10 12 13  10  14  15 12


    Enter the number of elements of array 2: 5


    Enter the elements of array 2:  17  12  10 19 12


    The common members of array1 and array2 are: 12  10



Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here