C Online Compiler
Example: Multiplication Table with User Input in C
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Multiplication Table with User Input #include <stdio.h> int main() { // Step 1: Declare a variable to store the number entered by the user. int number; // Step 2: Prompt the user to enter a number. printf("Enter a number to see its multiplication table: "); // Step 3: Read the integer input from the user. scanf("%d", &number); // Step 4: Loop from 1 to 10 to multiply the number. printf("\nMultiplication Table for %d:\n", number); for (int i = 1; i <= 10; i++) { // Step 5: Calculate the product. int product = number * i; // Step 6: Print the result in a formatted way. printf("%d x %d = %d\n", number, i, product); } return 0; }
Output
Clear
ADVERTISEMENTS