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 7(
Common Elements
)
Write a program named common elements.cpp that prompts the user to two arrays of 10 integers from standard input. Displays the common elements that appear in both arrays. Here is a sample run.
/workspace/csc117/hw7
% g++-o out/common_elements.out src/common_elements.cpp
%./out/common_elements.out
Enter 10 elements of array1: 85101616619112
Enter 10 elements of array2: 42310334356731
The common elements are: 1012
Hints:
Use two nested loops to check every possible pairs
a
i
, b
j
where
a
i
in
arr
1, and
b
j
in
arr
2. The outer loop goes through elements of array
arr
1, the inner loop goes through
elements of array
arr
2. 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!