Question: 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

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 Databases Questions!