C++ Online Compiler
Example: Multiplication Table of 7 in C++
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// Multiplication Table of 7 #include <iostream> // Required for input/output operations (cout) using namespace std; // Allows using names like cout and endl directly int main() { int number = 7; // The number for which we want to print the table // Step 1: Use a for loop to iterate from 1 to 10 // - Initialization: int i = 1; (starts the counter at 1) // - Condition: i <= 10; (loop continues as long as i is less than or equal to 10) // - Increment: ++i; (increments i by 1 after each iteration) for (int i = 1; i <= 10; ++i) { // Step 2: Calculate the product of 'number' and the current iterator 'i' int product = number * i; // Step 3: Print the multiplication expression and its result // For example, for i=1, it prints "7 x 1 = 7" cout << number << " x " << i << " = " << product << endl; } return 0; // Indicates successful program execution }
Output
Clear
ADVERTISEMENTS