Previous Next
0 / 15
Module DEMO-33-65DEMO-OOP-33

Simple Calculator

DEMO-OOP-33 โ€ข Object Oriented Programming

Browser-only practice

Problem Statement

Write a program that reads two integers and performs basic arithmetic operations on them. Your program should read two integers from the user and then output their sum, difference, product, and quotient (integer division).

For example, if the user enters 10 and 3, your program should calculate:

  • Sum: 10 + 3 = 13
  • Difference: 10 - 3 = 7
  • Product: 10 * 3 = 30
  • Quotient: 10 / 3 = 3 (integer division)

Note: For quotient calculation, you can assume the second number will never be zero.

Constraints

Both integers will be in the range [-1000, 1000] The second integer will never be zero Use only printf and scanf for input/output Do not use loops or arrays

Input Format

Two integers on a single line separated by a space.

Output Format

Four lines of output in the following format:

  1. Sum: [result]
  2. Difference: [result]
  3. Product: [result]
  4. Quotient: [result]

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
10 3
Sum: 13
Difference: 7
Product: 30
Quotient: 3
Basic test case with positive numbers. 10+3=13, 10-3=7, 10*3=30, 10/3=3
Sample #2
Public sample
15 5
Sum: 20
Difference: 10
Product: 75
Quotient: 3
Another positive number test case where division results in a whole number

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings