In this program, we are going to see how we can print the multiplication table of any user given input number.

Logic

Printing multiplication table of any number is quite simple and an easy task. After taking input (num) from the user we have to start one loop from 1 to 10, and then inside the loop simply multiply num by current number “i” and print it.

Program

#include <iostream>

using namespace std;

int main() {

    int i, num;

    // Take input from user
    cout << "Enter number to print table : ";
    cin >> num;

    cout << endl;

    for(i = 1; i <= 10; i++) {

        cout << num << " * " << i << " = " << (num * i) << endl;
    }

    return 0;
}

Output

Enter number to print table : 2
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
2 * 6 = 12
2 * 7 = 14
2 * 8 = 16
2 * 9 = 18
2 * 10 = 20