C++ Program to Generate Multiplication Table using do-while Loop

- March 13, 2018
Here is a simple program to define multiplication operation for an algebraic system. It inputs a number from the user and generates its table just using C++ do while loop and increment operator.

Logic of the Program

In this simple program, the following C++ techniques are used:


Program Source Code

#include<iostream>
 int main()
 {
     int num, table;
     std::  cout<<"Enter number for multiplication table:\n";
     std::  cin>>table;
     num = 1;
   do
      {
     std:: cout<<num<<"x"<<table<<"="<<table*num<<'\n';
          num++;
       } while (num <= 10); 
}


Output of Program

Enter number for multiplication table: 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

The multiplication table is an essential part of elementary arithmetic as it lays the foundation for arithmetic operations. The above C++ example program will quickly find out the table of any number.