C++ Program to Display Multiplication Table

Using for Loop

In the following example, we will create and display the Multiplication Table for the given number (9) using for loop

Example

C++ Compiler
#include <iostream> using namespace std; int main() { int table = 9; int length = 10; int i = 1; cout << "Multiplication table: " << table; for(i=1; i<=length; i++) cout << "\n" << i << " * " << table << " = " << i * table; return 0; }

Using while Loop

In the following example, we will create and display the Multiplication Table for the given number (9) using while loop

Example

C++ Compiler
#include <iostream> using namespace std; int main() { int table = 9; int length = 10; int i = 1; cout << "Multiplication table: " << table; while(i <= length) { cout << "\n" << i << " * " << table << " = " << i * table; i++; } return 0; }

Using do while Loop

In the following example, we will create and display the Multiplication Table for the given number (9) using do while loop

Example

C++ Compiler
#include <iostream> using namespace std; int main() { int table = 9; int length = 10; int i = 1; cout << "Multiplication table: " << table; do{ cout << "\n" << i << " * " << table << " = " << i * table; i++; }while(i <= length); return 0; }

Display Customized Table

In the following example, we will display the table according to the given table number and table length.

Example

C++ Compiler
#include <iostream> using namespace std; int main() { int table, length, i = 1; cout << "Enter a table number: "; cin >> table; cout << "Enter a length: "; cin >> length; cout << "\nMultiplication table: " << table; for(i=1; i<=length; i++) cout << "\n" << i << " * " << table << " = " << i * table; return 0; }

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author