Cpp program to the multiplication table
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.
Create a multiplication table using the for loop in C++ language
In this program, multiplication is created using for loop
Program 1
#include <iostream> #include <conio.h> 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<<num<<"x"<<i<<"="<<num*i<< endl;; } getch(); return 0; }
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 <iostream> #include <conio.h> 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<<num<<"x"<<i<<"="<<num*i<< endl;; } getch(); return 0; }
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
Create a multiplication table using the while loop in C++ language
Program 1
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<<num<<"x"<<i<<"="<<num*i<< endl; i++; } getch(); return 0; }
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 <iostream> #include <conio.h> 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<<num<<"x"<<i<<"="<<num*i<< endl; i++; } getch(); return 0; }
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 <iostream> #include <conio.h> using namespace std; int main() { int num; cout << "Enter the number :" << endl; cin>>num;//get input from user int i=1; do{ cout<<num<<"x"<<i<<"="<<num*i<< endl; i++; }while(i<=10); getch(); return 0; }
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 <iostream> #include <conio.h> 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<<num<<"x"<<i<<"="<<num*i<< endl; i++; }while(i<=range); getch(); return 0; }
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 <iostream> #include <conio.h> using namespace std; int main() { int i,j; cout<<"Multiplication table"<<endl; cout<<"Here, multiplication table"<<endl; for(i=1; i<=10; i++){ for(j=1; j<=10; j++){ cout<<"\t"<<i*j; } cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following results:

Multiplication table using nested while loop in C++ language
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j; cout<<"Multiplication table"<<endl; i=1; while(i<10){ j=1; while(j<10){ cout<<"\t"<<i*j; j++; } i++; cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following results:

Multiplication table using the nested d0-while loop in C++ language
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j; i=1; cout<<"Multiplication table"<<endl; cout<<"Here multiplication table\n\n"; do{ j=1; do{ cout<<"\t"<<i*j; j++; }while(j<10); cout<<"\n"; i++; }while(i<10); getch(); return 0; }
When the above code is executed, it produces the following results:

Similar post
Python program to display the multiplication table
Java program to display the multiplication table
Cpp program to print multiplication table
C program to display multiplication table
Java program to display the multiplication table using array
Suggested for you
Nested for loop in Java language
Nested for loop in C++ language
Nested for loop in Python language