In this tutorial, we will discuss the Cpp program to multiplication tableCreate multiplication table using loops.
We will learn how to create a multiplication table using loops. we can create multiplication table using for loop, while loop and do – while loop in C++ language.
In this program, multiplication is created using for loop
Program 1
#include
#include
using namespace std;
int main()
{
int num=1;
cout << "Enter the number :" << endl;
cin>>num; //get input from user
for(int i=1; i<=10; i++){
cout<
When the above code is executed, it produces the following results:
Enter the number:
12
12x1=12
12x2=24
12x3=36
12x4=48
12x5=60
12x6=72
12x7=84
12x8=96
12x9=108
12x10=120
Program 2
In this program, the user can provide a needed range according to their preference and produced their all multiplication table according to the value provided
#include
#include
using namespace std;
int main()
{
int num=1,range;
cout << "Enter the number :" << endl;
cin>>num;
cout << "Enter the range :" << endl;
cin>>range;
for(int i=1; i<=range; i++){
cout<
When the above code is executed, it produces the following results:
Enter the number:
13
Enter the range:
12
13x1=13
13x2=26
13x3=39
13x4=52
13x5=65
13x6=78
13x7=91
13x8=104
13x9=117
13x10=130
13x11=143
13x12=156
in this program, the user can provide a needed range according to their preference and produced their all multiplication table according to the value provided
In this program, multiplication is created using while loop.
using namespace std;
int main()
{
int num=1;
cout << "Enter the number :" << endl;
cin>>num;
int i=1;
while(i<=10){
cout<
When the above code is executed, it produces the following results:
Enter the number:
12
12x1=12
12x2=24
12x3=36
12x4=48
12x5=60
12x6=72
12x7=84
12x8=96
12x9=108
12x10=120
Program 2
In this program, the user can provide a needed range according to their preference and produced their all multiplication table according to the value provided
#include
#include
using namespace std;
int main()
{
int num,range;
cout << "Enter the number :" << endl;
cin>>num; //get input from user
cout << "Enter the range :" << endl;
cin>>range; //get input from user
int i=1;
while(i<=range){
cout<
When the above code is executed, it produces the following results:
Enter the number:
11
Enter the range:
12
11x1=11
11x2=22
11x3=33
11x4=44
11x5=55
11x6=66
11x7=77
11x8=88
11x9=99
11x10=110
11x11=121
11x12=132
Create a multiplication table using the do-while loop in C++ language
Program 1
In this program, multiplication is created using the do-while loop.
#include
#include
using namespace std;
int main()
{
int num;
cout << "Enter the number :" << endl;
cin>>num;//get input from user
int i=1;
do{
cout<
When the above code is executed, it produces the following results:
Enter the number:
13
13x1=13
13x2=26
13x3=39
13x4=52
13x5=65
13x6=78
13x7=91
13x8=104
13x9=117
13x10=130
Program 2
In this program, the user can provide a needed range according to their preference and produced their all multiplication table according to the value provided
#include
#include
using namespace std;
int main()
{
int num,range;
cout << "Enter the number :" << endl;
cin>>num;
cout << "Enter the range :" << endl;
cin>>range;
int i=1;
do{
cout<
When the above code is executed, it produces the following results:
Enter the number:
9
Enter the range:
13
9x1=9
9x2=18
9x3=27
9x4=36
9x5=45
9x6=54
9x7=63
9x8=72
9x9=81
9x10=90
9x11=99
9x12=108
9x13=117
Another form of the multiplication table
Multiplication table using nested for loop in C++ language
Cpp program to multiplication table
#include
#include
using namespace std;
int main()
{
int i,j;
cout<<"Multiplication table"<
When the above code is executed, it produces the following results:
Multiplication table
Multiplication table using nested while loop in C++ language
#include
#include
using namespace std;
int main()
{
int i,j;
cout<<"Multiplication table"<
When the above code is executed, it produces the following results: