C Online Compiler
Example: User-Defined Multiplication Table in C
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// User-Defined Multiplication Table #include <stdio.h> int main() { // Step 1: Declare variables int number; // Variable to store user input int i = 1; // Loop counter // Step 2: Prompt user for input printf("Enter a number to see its multiplication table: "); scanf("%d", &number); // Read the integer input from the user printf("Multiplication Table of %d:\n", number); // Step 3: Use a while loop to iterate from 1 to 10 while (i <= 10) { // Step 4: Calculate and print each line printf("%d x %d = %d\n", number, i, (number * i)); // Step 5: Increment the counter i++; } return 0; }
Output
Clear
ADVERTISEMENTS