C++ Program to Print Multiplication Table of a Number

In the previous article, we have discussed C++ Program Linear Search in Array. In this article, we will see C++ Program to Print Multiplication Table of a Number.

C++ Program to Print Multiplication Table of a Number

  • Write a C++ program to print multiplication table of a number.

To print multiplication table, we first take a number n and term(t) as input from user. We will use a for loop to print the multiplication table of n till t times.

C++ Program to Generate Multiplication Table

C++ Program to Generate Multiplication Table

#include <iostream>
 
using namespace std;
 
int main() {
    int n, term, i;
     
    cout << "Enter a number to print multiplication table\n";
    cin >> n;
    cout << "Enter number of terms in table\n";
    cin >> term;
    /* Generate multiplication table */
    for(i = 1; i <= term; ++i){
        cout << n << " X " << i << " = " << n*i << endl;
    }
      
    return 0;
}

Output

Enter a number to print multiplication table
6
Enter number of terms in table
9
6 X 1 = 6
6 X 2 = 12
6 X 3 = 18
6 X 4 = 24
6 X 5 = 30
6 X 6 = 36
6 X 7 = 42
6 X 8 = 48
6 X 9 = 54

Are you fed up with browsing all concepts related to C++ Programming Programs? Not anymore because all the basic and complex Programs for C++ are covered on our main page just tap on the link available here & save your time to practice more.