422
In this example we show how to generate a multiplication table in C++
Example
We take input from the user and then use a for loop to display the table
#include <iostream> using namespace std; int main() { int number; cout << "Enter a positive integer: "; cin >> number; for (int i = 1; i <= 10; ++i) { cout << number << " * " << i << " = " << number * i << endl; } return 0; }
When you run this you will see something like this
Enter a positive integer: 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