In this tutorial, we will write a C program to print a multiplication table for any number. Before that, you may go through the following topic in C.
C Program to Print Multiplication Table using While loop
Source code: The user needs to enter the number for which the table is to be printed and a program using while loop prints the multiplication table for that number.
#include <stdio.h>
int main()
{
int num, i = 1;
printf("Enter the Number: ");
scanf("%d", &num);
printf("Multiplication table of %d:\n\n", num);
while (i <= 10)
{
printf(" %d x %d = %d \n ", num, i, num *i);
i++;
}
return 0;
}
Output:
Enter the Number: 2
Multiplication table of 2:
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
2 x 4 = 8
2 x 5 = 10
2 x 6 = 12
2 x 7 = 14
2 x 8 = 16
2 x 9 = 18
2 x 10 = 20