# Multiplication Table in C++

In this article, we will discuss the multiplication table programs in C++ with different cases.

### Case 1:

Take a number from the user as input, and print the multiplication table for that number.

C++ program:

Output:

Explanation:

In the above cpp program, an input should be taken from the user that represents the number for multiplication. After that, a for loop is used to iterate through numbers from one to ten. In print statements, we multiply the number with the input so that we get the multiplication table from one to 10. So that the loop will terminate and the main function will end by returning zero.

### Case 2:

Take a number from the user as input, and print the multiplication table for that number without using the multiplication operator.

C++ program:

Output:

Explanation:

In the above c++ program, an input should be taken from the user that represents the number for multiplication. After that, a for loop is used to iterate through numbers from one to 10. In print statements, we declared a variable named sum and initialized it to the value of the number. Now for every iteration, we update the sum value by adding the number to the sum and print this sum. So that the loop will terminate and the main function will end by returning zero. This is how we print the multiplication table of a number.

### Case 3:

Take a number from the user as input, and print the multiplication table within a given range.

C++ program:

Output:

Explanation:

In the above c++ program, an input should be taken from the user that represents the number for multiplication. It takes two more inputs from the user one indicates the starting of the range and the other indicates the ending of the range. After that, a for loop is used to iterate through numbers from one to ten. In print statements, we multiply the number with the input so that we get the multiplication table from one to ten. So that the loop will terminate and the main function will end by returning zero. It is how we print the multiplication table of a number.

### Case 4:

Take a number from the user as input, and print the multiplication table for that number using the recursion.

C++ program:

Output:

Explanation:

In the above program, there are two functions one is the main function and the other is the printMultiplicationTable. This printMultiplicationTable function will take two parameters one is number and the other is current. Number is the value to get the multiplication table and current is used to keep track of the current multiplier.

Inside the function, the base condition will be current less than or equal to the ten. If the current is greater than ten the recursion will be stopped. If the current is within the desired range, we proceed to print the multiplication of the number and current. It shows the current line of the multiplication table.

After that, we make a recursive call to printMultiplicationTable, incrementing the current by one. This recursive call continues until "current" exceeds ten, at which point the recursion stops due to the base case.