Question: Problem 7 ( Common Elements ) Write a program named common elements.cpp that prompts the user to two arrays of 1 0 integers from standard
Problem
Common Elements
Write a program named common elements.cpp that prompts the user to two arrays of integers from standard input. Displays the common elements that appear in both arrays. Here is a sample run.
workspacecschw
go outcommonelements.out srccommonelements.cpp
outcommonelements.out
Enter elements of array:
Enter elements of array:
The common elements are:
Hints:
Use two nested loops to check every possible pairs
a
i
b
j
where
a
i
in
arr
and
b
j
in
arr
The outer loop goes through elements of array
arr
the inner loop goes through
elements of array
arr
In each iteration, if
a
i
b
j
displays
a
i
as a common element of the
two arrays
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
