Question: Write a C++ program that accepts 5 numbers from the user and then uses selection structures to determine the largest TWO numbers out of those
Write a C++ program that accepts 5 numbers from the user and then uses selection structures to determine the largest TWO numbers out of those 5. Your output should say, "The largest number is: " and then give the largest number and then on the next line "The second largest number is: " and then give the second largest number.
CLARIFICATION: you may assume that all the numbers are positive integers greater than 0.
Hint: you should use two variables, one that is used to store the largest number so far, and one used to store the second largest number so far. Then process each of the 5 values one at a time.
Suggestion: it might be easier to start by just finding the largest number of the five.
without using loops (no loops allowed)
Language: C++
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
