Basic Arithmetic Operations

Basic Arithmetic Operations

Easy C++ Operators 44 views
Explanation Complexity

Problem Statement

Perform all basic math operations on two numbers.
Real Life: Like using calculator for daily calculations.

Input Format

Two integers a and b.

Output Format

Results of basic mathematical operations:

• Addition

• Subtraction

• Multiplication

• Division

• Modulus

Example

10 5
Addition = 15
Subtraction = 5
Multiplication = 50
Division = 2
Modulus = 0

Constraints

• Integers only

• b should not be 0 for division and modulus

Concept Explanation

Basic math operations are used in daily life, just like a calculator.
Each operator performs a different calculation on the same two numbers.

Step-by-Step Explanation

1.Take two numbers a and b.

2.Calculate addition using a + b.

3.Calculate subtraction using a - b.

4.Calculate multiplication using a * b.

5.Calculate division using a / b.

6.Calculate modulus using a % b.

7.Print the result of each operation.

Concept Explanation

Basic math operations are used in daily life, just like a calculator.
Each operator performs a different calculation on the same two numbers.

Step-by-Step Explanation

1.Take two numbers a and b.

2.Calculate addition using a + b.

3.Calculate subtraction using a - b.

4.Calculate multiplication using a * b.

5.Calculate division using a / b.

6.Calculate modulus using a % b.

7.Print the result of each operation.

Input / Output Format

Input Format
Two integers a and b.
Output Format
Results of basic mathematical operations:

• Addition

• Subtraction

• Multiplication

• Division

• Modulus
Constraints
• Integers only

• b should not be 0 for division and modulus

Examples

Input:
10 5
Output:
Addition = 15 Subtraction = 5 Multiplication = 50 Division = 2 Modulus = 0

Example Solution (Public)

C++
void operator_q1_arithmetic() {
    int a = 25;
    int b = 4;
    
    cout << "Number 1: " << a << ", Number 2: " << b << endl;
    cout << "Addition: " << a + b << endl;
    cout << "Subtraction: " << a - b << endl;
    cout << "Multiplication: " << a * b << endl;
    cout << "Division: " << a / b << endl;
    cout << "Modulus (remainder): " << a % b << endl;
}

Official Solution Code

void operator_q1_arithmetic() {
    int a = 25;
    int b = 4;
    
    cout << "Number 1: " << a << ", Number 2: " << b << endl;
    cout << "Addition: " << a + b << endl;
    cout << "Subtraction: " << a - b << endl;
    cout << "Multiplication: " << a * b << endl;
    cout << "Division: " << a / b << endl;
    cout << "Modulus (remainder): " << a % b << endl;
}
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.