Print Table of any Number in C++

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 Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements