Skip to content

Practice Problem 3

Seanti edited this page Mar 26, 2025 · 1 revision

Problem:

Create a program that asks the user for two numbers and then calculates and displays:

  • Sum

  • Difference

  • Product

  • Quotient (handle division by zero properly)

  • Remainder

Sample Output:

Enter first number: 15  
Enter second number: 4  
Sum: 19  
Difference: 11  
Product: 60  
Quotient: 3  
Remainder: 3  

If the user tries to divide by zero:

Enter first number: 10  
Enter second number: 0  
Division by zero is not allowed.

Clone this wiki locally