Print Table of any Number in C++

Google Advertisements

Prev Tutorial Next Tutorial

C++ program to Print Table of any Number

The concept of generating table of any number is multiply particular number from 1 to 10.
num * 1
num * 2
num * 3
num * 4
num * 5
num * 6
num * 7
num * 8
num * 9
num * 10

Example

#include<iostream.h>
#include<conio.h>

void main()
{
int i,no,table=1;
clrscr();
cout<<"Enter any num : ";
cin>>no;
clrscr();
cout<<"Table of "<<no;
for(i=1;i< =10;i++)
{
table=no*i;
cout<<" \n"<<table;
cout<<"\n";
}
getch();
}

Output

Enter any num : 5
Table of 5
5
10
15
20
25
30
35
40
45
50

Explanation of Program

Code

for(i=1;i< =10;i++)
{
table=no*i;
cout<<" \n"<<table;
cout<<"\n";
}

In the above Code execute for loop from 1 to 10, and given number is multiply by 1 and next iteration number is multiply by 2 and at third iteration number is multiply by 3,........10. and there results are print on screen

Table using while loop

#include<iostream.h>
#include<conio.h>

void main()
{
int a=1,no,table=1;
clrscr();
cout<<"Enter any num: ";
cin>>no;
while(a< =10)
{
table=a*no;
cout<<table;
cout<<"\n";
a++;
}
getch();
}

Output

Enter any num: 2
Table
2
4
6
8
10
12
14
16
18
20

Prev Tutorial Next Tutorial

Google Advertisements

We have more than 5 Groups which have 500000+ Members and some Pages have more than 100000+ members. For Advertisement contact on [email protected] or 8076671483

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: [email protected] or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Classpath variable is set for providing a path for predefined Java classes which is used in our application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar. Difference between path and classpath in Java

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements


Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: [email protected] or 8076671483 Try this Keyword C++ Programs