# C++ Program to Generate Multiplication Table

C++ProgrammingServer Side Programming

The multiplication table is used to define a multiplication operation for any number. It is normally used to lay the foundation of elementary arithmetic operations with base ten numbers.

The multiplication table of any number is written till 10. In each row, the product of the number with 1 to 10 is displayed. An example of the multiplication table of 4 is as follows −

4 * 1 = 4
4 * 2 = 8
4 * 3 = 12
4 * 4 = 16
4 * 5 = 20
4 * 6 = 24
4 * 7 = 28
4 * 8 = 32
4 * 9 = 36
4 * 10 = 40

A program that generates the multiplication table of the given number is as follows.

## Example

Live Demo

#include <iostream>
using namespace std;
int main() {
int n = 7, i;
cout<<"The multiplication table for "<< n <<" is as follows:"<< endl;
for (i = 1; i <= 10; i++)
cout << n << " * " << i << " = " << n * i << endl;
return 0;
}

## Output

The multiplication table for 7 is as follows:
7 * 1 = 7
7 * 2 = 14
7 * 3 = 21
7 * 4 = 28
7 * 5 = 35
7 * 6 = 42
7 * 7 = 49
7 * 8 = 56
7 * 9 = 63
7 * 10 = 70

In the above program, a for loop is used from 1 to 10. In each iteration of the for loop, the number is multiplied with i and the product is displayed. This is demonstrated by the following code snippet.

for (i = 1; i <= 10; i++)
cout << n << " * " << i << " = " << n * i <<endl;

Published on 27-Sep-2018 08:57:20