 # C++ Program to Generate multiplication table

In this C++ program, we are generating the multiplication table of a user-entered number.

## How can we generate a multiplication table?

A multiplication table is a mathematical table used to define a multiplication operation for an algebraic system. Multiplication is a mathematical operation.
for a and b are positive integers, a*b  means a is to be added to itself as many times as there are units in b.
for example, 2*3 means 2 is added 3 times itself or 3 is added 2 times itself.
2*3 = 6; 2+2+2 = 6.

Mutiplication table of a can be generated by multiplying a with b where the value of b is changed after each step. a*b where b=(1,2,3......................)

## How can we generate a multiplication table using C++?

Here we are generating a C++ program to generate the multiplication table of a user-entered positive integer up to 10 only. So, first read a number n from the user and store the value into an integer type variable n. Here we are using a `for loop` for generating the multiplication table.
Syntax of `for loop`
```for ( initialization; condition; update ) { body of loop }```
Here, we start our multiplication from 1 so initializei =1; The table computes up to 10 so our condition is i<=10; The value of I must be updated after each execution of the body of the loop.so i is incremented or added by 1. The multiplication process which is to be repeated will be coded in the body of the loop.
Print each execution result on the screen.

Algorithm

Step 1:  Call the header file` iostream`.

Step 2: Use the `namespace std.`

Step 3: Open the integer type main function;` int main().`

Step 4: Declare integer variable n;

Step 5: Print a message to enter a positive integer.

Step 6: Read the number into the variable n.

Step 7: using a for loop find the product of the number n up to 10

Step 8: print the result.

Step 9: Exit.

## C++ Source Code

```                                          ```#include <iostream>
using namespace std;

int main()
{
int n;

cout << "Enter a positive integer: ";
cin >> n;

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

return 0;
}```
```

## OUTPUT

```Enter a positive integer: 6
6 * 1 = 6
6 * 2 = 12
6 * 3 = 18
6 * 4 = 24
6 * 5 = 30
6 * 6 = 36
6 * 7 = 42
6 * 8 = 48
6 * 9 = 54
6 * 10 = 60
```
VIEW ALL
VIEW ALL
VIEW ALL