➤ Program to print multiplication table using while loop.
#include<stdio.h> int main() { int i=1,n; printf("Enter the value of n: "); scanf("%d",&n); while(i<=10) { printf("%d x %d = %d\n",n,i,n*i); i++; } return 0; }OUTPUT :
Enter the value of n: 5 5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 5 x 5 = 25 5 x 6 = 30 5 x 7 = 35 5 x 8 = 40 5 x 9 = 45 5 x 10 = 50 Enter the value of n: 18 18 x 1 = 18 18 x 2 = 36 18 x 3 = 54 18 x 4 = 72 18 x 5 = 90 18 x 6 = 108 18 x 7 = 126 18 x 8 = 144 18 x 9 = 162 18 x 10 = 180
➤ Program to print the multiplication table using while loop in reverse order .
#include<stdio.h> int main() { int i=10,n; // In case you print table 20 while using int i = 20,n; printf("Enter the value of n: "); //Enter the number multiplication table want to print scanf("%d",&n); while(i) { printf("%d x %d = %d\n",n,i,n*i); i--; } return 0; }OUTPUT :
Enter the value of n: 5 5 x 10 = 50 5 x 9 = 45 5 x 8 = 40 5 x 7 = 35 5 x 6 = 30 5 x 5 = 25 5 x 4 = 20 5 x 3 = 15 5 x 2 = 10 5 x 1 = 5 Enter the value of n: 15 15 x 10 = 150 15 x 9 = 135 15 x 8 = 120 15 x 7 = 105 15 x 6 = 90 15 x 5 = 75 15 x 4 = 60 15 x 3 = 45 15 x 2 = 30 15 x 1 = 15