Write a C++ Program to Find Multiplication Table of the Entered Number

Multiplication Table

Mathematics is one of the easiest things to play while you do C or C++ Programming; Here in this program we are going to write a program to find multiplication table of the entered number;

Like, (X*A = Z) (2*2 = 4)

Here we are finding multiplication table of user inputted any number;

Also, we will be using for loop here;

For Loop is the repetition control structure which can be used in C and C++ for repeating the same value during program execution.

for(a=1; a<=10; a=a+1){
z=x*a;
cout<<"The Table is:"<<x<<"*"<<a<<"=" <<z<<endl;
}

Now let’s try to write a program to find multiplication table by using for loop;

C++ Program to Find Multiplication Table of the Entered Number

#include <iostream>
#include <cstdlib>

using namespace std;

int main(int argc, char** argv) {

int x, a=1, z;

cout<<"Enter the number to Find Table:"<<endl;
cin>>x;

for(a=1; a<=10; a=a+1){
z=x*a;
cout<<"The Table is:"<<x<<"*"<<a<<"=" <<z<<endl;
}

return 0;
}

Here we have defined three variables to take input x as a value which will be entered by the user, z variable will store the value and a=1 is to increment the value up to 10 the position to find the multiplication;

Output

Enter the number to Find Table:
2000
The Table is:2000*1=2000
The Table is:2000*2=4000
The Table is:2000*3=6000
The Table is:2000*4=8000
The Table is:2000*5=10000
The Table is:2000*6=12000
The Table is:2000*7=14000
The Table is:2000*8=16000
The Table is:2000*9=18000
The Table is:2000*10=20000

RUN SUCCESSFUL (total time: 3s)

That’s all, there are other ways to control the structure like a while, do while and etc… stay tuned for those updates;

Leave a Reply

Your email address will not be published. Required fields are marked *