Write a program that repeatedly asks the user to enter integer numbers (validation is not necessary). The program should continue to read numbers from the user until they enter a negative number (e.g., 3, 7, 3, 1, 6, 4, -1). Once the user enters a negative number, the program should stop repeating the prompt and print out the second largest number that the user has entered. You can assume the user will enter at least two non-negative (non-zero) numbers. Note: you may not use lists or other summary functions (max, min, etc.) for this problem. You should only need input/variables/looping/branching structures. Example: Enter positive integers: 3, 7, 3, 1, 6, 4, -1 The second largest number is: 6

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.5: A Closer Look: Loop Programming Techniques
Problem 14E
icon
Related questions
Question

Write a program that repeatedly asks the user to enter integer numbers (validation is not necessary). The program should continue to read numbers from the user until they enter a negative number (e.g., 3, 7, 3, 1, 6, 4, -1). Once the user enters a negative number, the program should stop repeating the prompt and print out the second largest number that the user has entered. You can assume the user will enter at least two non-negative (non-zero) numbers. Note: you may not use lists or other summary functions (max, min, etc.) for this problem. You should only need input/variables/looping/branching structures.
Example:
Enter positive integers: 3, 7, 3, 1, 6, 4, -1 The second largest number is: 6

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT