Program to Print Table of Any Number in C++
Here you will get a program to print table of any number in C++ programming. It will take a number as input, start loop from 1 to 10 and print the multiplication of given number.
C++ program to print table of any number using for loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include<iostream> using namespace std; int main() { int i,num; cout<<"Enter a number : "; cin>>num; for(i=1;i<=10;i++) { cout<<"\n"<<num<<" * "<<i<<" = "<<num*i<<endl;; } return 0; } |
Output
Enter a number : 7
7 * 1 = 7
7 * 2 = 14
7 * 3 = 21
7 * 4 = 28
7 * 5 = 35
7 * 6 = 42
7 * 7 = 49
7 * 8 = 56
7 * 9 = 63
7 * 10 = 70
C++ program to print table of any number using while loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include<iostream> using namespace std; int main() { int i=1,num; cout<<"Enter a number : "; cin>>num; while(i<=10) { cout<<"\n"<<num<<" * "<<i<<" = "<<num*i<<endl; i++; } return 0; } |
Output
Enter a number : 7
12 * 1 = 12
12 * 2 = 24
12 * 3 = 36
12 * 4 = 48
12 * 5 = 60
12 * 6 = 72
12 * 7 = 84
12 * 8 = 96
12 * 9 = 108
12 * 10 = 120
Check out our other C++ programming Examples