C++ Program to Print Multiplication Table using For loop
ADVERTISEMENTS
C++ program to print multiplication table using for loop. In this article, you will learn how to make a C++ program to print multiplication table using for loop.
Source Code
// C++ Program to Print Multiplication Table using For loop
#include <iostream>
using namespace std;
int main() {
int x, r, i;
// x - To store the input number
// r - To store the multiplication range
cout << "----Enter the input number is::---\n";
cin >> x;
cout << "\n----Enter the range number is::----\n";
cin >> r;
cout << "\n\n------The above multiplication table--------\n\n";
for (i = 1; i <= r; i++) {
cout << x << " * " << i << " = " << x * i << "\n";
}
return 0;
}
Output
----Enter the input number is::---
21
----Enter the range number is::----
13
------The above multiplication table--------
21 * 1 = 21
21 * 2 = 42
21 * 3 = 63
21 * 4 = 84
21 * 5 = 105
21 * 6 = 126
21 * 7 = 147
21 * 8 = 168
21 * 9 = 189
21 * 10 = 210
21 * 11 = 231
21 * 12 = 252
21 * 13 = 273