C Online Compiler
Example: Multiplication Table using For Loop in C
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Multiplication Table using For Loop #include <stdio.h> int main() { // Step 1: Declare variables to store the user's number and the loop counter. int num; int i; // Step 2: Prompt the user to enter a number. printf("Enter an integer: "); // Step 3: Read the integer input from the user. scanf("%d", &num); // Step 4: Print a header for the multiplication table. printf("\nMultiplication Table of %d:\n", num); // Step 5: Use a for loop to iterate from 1 to 10. for (i = 1; i <= 10; ++i) { // Step 6: Inside the loop, calculate and print each line of the table. // Format: number x multiplier = product printf("%d x %d = %d\n", num, i, num * i); } return 0; }
Output
Clear
ADVERTISEMENTS