By: Prem Tiwari | Last Updated: | In: C++ Tutorial
If you want to write a C++ program to print number table, then this tutorial is specially designed for you. Please keep your close attention in this post as I am going to share a C++ program to print number table while executing below C++ program.
In this program, we have to get input from the user and the multiply that number with “i” variable to print the number table with the help of the for a loop. Copy and paste below code to print the number table of an entered number by the user.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include <iostream> using namespace std; int main() { int num, i, tab; cout<<"Enter a number: "; cin>>num; cout<<"Table of "<<num<<" is \n\n"; for(i=1; i<=10; i++) { tab=num*i; cout<<num<<" * "<<i<<" = "<<tab<<"\n"; } } |
Enter a number: 4
4 * 1 = 4
4 * 2 = 8
4 * 3 = 12
4 * 4 = 16
4 * 5 = 20
4 * 6 = 24
4 * 7 = 28
4 * 8 = 32
4 * 9 = 36
4 * 10 = 40
Prem Tiwari is the founder of FreeWebMentor.com and also a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies. View all posts by Prem Tiwari
Tags: c programs, c++ examples, c++ program to print number table, C++ Tutorial, number table