Print Multiplication Table

Print Multiplication Table

Medium C++ Control Flow 41 views
Explanation Complexity

Problem Statement

Print multiplication table of any number (like 5 × 1 = 5, 5 × 2 = 10...)
Real Life: Like the multiplication tables you learn in school.

Input Format

An integer N (number whose table is to be printed).

Output Format

Multiplication table of N from 1 to 10.

Example

5
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50

Constraints

• N is an integer

• Typically print table up to 10

Concept Explanation

A multiplication table shows the result of multiplying a number by 1 to 10.
This is the same concept taught in school.

Step-by-Step Explanation

1.Take input number N.

2.Loop i from 1 to 10.

3.For each i, calculate N * i.

4.Print in the format: N x i = result.

5.Continue until i = 10.

Concept Explanation

A multiplication table shows the result of multiplying a number by 1 to 10.
This is the same concept taught in school.

Step-by-Step Explanation

1.Take input number N.

2.Loop i from 1 to 10.

3.For each i, calculate N * i.

4.Print in the format: N x i = result.

5.Continue until i = 10.

Input / Output Format

Input Format
An integer N (number whose table is to be printed).
Output Format
Multiplication table of N from 1 to 10.
Constraints
• N is an integer

• Typically print table up to 10

Examples

Input:
5
Output:
5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 5 x 5 = 25 5 x 6 = 30 5 x 7 = 35 5 x 8 = 40 5 x 9 = 45 5 x 10 = 50

Example Solution (Public)

C++
void control_q7_multiplication_table() {
    int number = 7;
    
    cout << "Multiplication table of " << number << ":" << endl;
    
    for(int i = 1; i <= 10; i++) {
        cout << number << " x " << i << " = " << number * i << endl;
    }
}

Official Solution Code

void control_q7_multiplication_table() {
    int number = 7;
    
    cout << "Multiplication table of " << number << ":" << endl;
    
    for(int i = 1; i <= 10; i++) {
        cout << number << " x " << i << " = " << number * i << endl;
    }
}
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.