Example Program For Multiplication Value Using For Loop In C++
On this page (6sections)
About this program
This is an example program in c common example program. Read the concept first: C++ Variables and Data Types, then study the code and output below.
Multiplication Table (Values) Using For Loop
/* Example Program For Multiplication Table (Values) Using For Loop In C++
little drops @ thiyagaraaj.com
*/
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
// Variable Declaration
int table, range;
// Get Input Value multiplication table
cout << "Enter the multiplication table you want to print : ";
cin >> table;
// Get Input Value for Range
cout << "Enter the range: ";
cin >> range;
//for Loop Block
for (int i = 1; i <= range; ++i) {
cout << table << " * " << i << " = " << table * i << endl;
}
// Wait For Output Screen
getch();
return 0;
}
Sample Output
Enter the multiplication table you want to print : 2
Enter the range: 64
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
2 * 6 = 12
2 * 7 = 14
2 * 8 = 16
2 * 9 = 18
2 * 10 = 20
2 * 11 = 22
2 * 12 = 24
2 * 13 = 26
2 * 14 = 28
2 * 15 = 30
2 * 16 = 32
2 * 17 = 34
2 * 18 = 36
2 * 19 = 38
2 * 20 = 40
2 * 21 = 42
2 * 22 = 44
2 * 23 = 46
2 * 24 = 48
2 * 25 = 50
2 * 26 = 52
2 * 27 = 54
2 * 28 = 56
2 * 29 = 58
2 * 30 = 60
2 * 31 = 62
2 * 32 = 64
2 * 33 = 66
2 * 34 = 68
2 * 35 = 70
2 * 36 = 72
2 * 37 = 74
2 * 38 = 76
2 * 39 = 78
2 * 40 = 80
2 * 41 = 82
2 * 42 = 84
2 * 43 = 86
2 * 44 = 88
2 * 45 = 90
2 * 46 = 92
2 * 47 = 94
2 * 48 = 96
2 * 49 = 98
2 * 50 = 100
2 * 51 = 102
2 * 52 = 104
2 * 53 = 106
2 * 54 = 108
2 * 55 = 110
2 * 56 = 112
2 * 57 = 114
2 * 58 = 116
2 * 59 = 118
2 * 60 = 120
2 * 61 = 122
2 * 62 = 124
2 * 63 = 126
2 * 64 = 128
How It Works
This C++ program demonstrates For Multiplication Value Using For Loop. It first reads the required values as input, then walks through the data with a loop to compute the result, and finally prints the output shown in the Sample Output above.
- Declare the variables that hold the program’s data.
- Read the input values that the program will work with.
- Iterate over the data using a loop to apply the logic.
- Print the final result to the console so you can compare it with the sample output.
Try changing the input values and re-running the program to see how the output changes — this is the fastest way to understand how the logic behaves.
Related Pages
Learn the concept first, then study the code:
- C++ Programs — Browse all C++ Programs.
- C++ Variables and Data Types — Tutorial — data types and variable declaration.
- Factorial Using Loop Example Program In C++ — More in c common example program.
- Factorial Using Function Example Program In C++ — More in c common example program.
Frequently Asked Questions
What does this C++ program do?
It is a C++ example program that demonstrates For Multiplication Value Using For Loop, including the complete source code and the expected sample output.
How do I compile and run this C++ program?
Save the code in a `.cpp` file, compile it with `g++ filename.cpp -o program`, then run it with `./program` (or `program.exe` on Windows).
What concepts does this example use?
This example uses loops to iterate over data, reading user input and user-defined functions, illustrating a common pattern in C++ programming.