Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that prompts the user to enter two integers and compares them. If the numbers are invalid (smaller than 1), the program

Write a C++ program that prompts the user to enter two integers and compares them.

If the numbers are invalid (smaller than 1), the program prints error message and exit. If the numbers are equal, the program prints that the numbers are equal and ends. If the numbers are not equal, the program prints the larger number. Then, the program checks whether the larger number is divisible by the other one and displays a message accordingly (You must use nested if).

Here are sample runs:

Enter two integers: 2 3

3 is larger than 2

3 is not divisible by 2

Enter two integers: 4 2

4 is larger than 2

4 is divisible by 2

Enter two integers: 5 5

5 is equal to 5

Enter two integers: 0 9

Input must be greater than 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started