Sure, here's a C program that takes input from the user and prints the multiplication table of that number:
Write a C program to input a number form user and print table of that number on screen#include <stdio.h>
int main() {
int num, i;
// Input number from 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;
}
In this program, we first declare two variables num and i. Then we use printf and scanf functions to get the input number from the user. We print a message asking the user to enter a number, and then we use the %d format specifier with scanf to read the input number and store it in the num variable.
After that, we use a for loop to print the multiplication table of that number. The loop runs from i = 1 to i = 10, and for each value of i, we use printf to print the product of num and i.
Finally, we return 0 from the main function to indicate successful program execution.
Post a Comment