#include <stdio.h>
int main() {
int num, i;
// Input the number from the user
printf("Enter a number: ");
scanf("%d", &num);
// Print the multiplication table
printf("Multiplication Table of %d:\n", num);
for (i = 1; i <= 10; i++) {
printf("%d x %d = %d\n", num, i, num * i);
}
return 0;
}
Explanation:
User Input: The program asks the user to input a number.
Multiplication Loop: It uses a for
loop to print the multiplication table from 1 to 10. For each iteration, it multiplies the entered number by the current loop index (i
).
Output: The result of each multiplication is printed in the format: num x i = result
.
End: The program completes after printing the full table.
Output:
Enter a number: 12
Multiplication Table of 12:
12 x 1 = 12
12 x 2 = 24
12 x 3 = 36
12 x 4 = 48
12 x 5 = 60
12 x 6 = 72
12 x 7 = 84
12 x 8 = 96
12 x 9 = 108
12 x 10 = 120