C program to print multiplication table; In this tutorial, we will learn how to print multiplication table in c program with the help of for loop and while loop.
Programs to Print Multiplication Table in C
- Algorithm of Print Multiplication Table
- C Program to Print Multiplication Table using For Loop
- C Program to Print Multiplication Table using While Loop
Algorithm of Print Multiplication Table
Use the algorithm to write a c program to print multiplication table; as follows:
- Step 1: Start.
- Step 2: Read the a number from the user.
- Step 3: Iterate for or while loop.
- Step 4: Print table of given number.
- Step 6:End.
C Program to Print Multiplication Table using For Loop
#include <stdio.h> int main() { int n, i; printf("Enter an integer: "); scanf("%d", &n); for (i = 1; i <= 10; ++i) { printf("%d * %d = %d \n", n, i, n * i); } return 0; }
The output of the above c program; as follows:
Enter an integer: 9 9 * 1 = 9 9 * 2 = 18 9 * 3 = 27 9 * 4 = 36 9 * 5 = 45 9 * 6 = 54 9 * 7 = 63 9 * 8 = 72 9 * 9 = 81 9 * 10 = 90
C Program to Print Multiplication Table using While Loop
#include <stdio.h> int main() { int n, i; printf("Enter a Number "); scanf("%d",&n); i=1; while(i<=10){ printf("%d * %d = %d \n", n, i, n*i); ++i; } return 0; }
The output of the above c program; as follows:
Enter a Number 12 12 * 1 = 12 12 * 2 = 24 12 * 3 = 36 12 * 4 = 48 12 * 5 = 60 12 * 6 = 72 12 * 7 = 84 12 * 8 = 96 12 * 9 = 108 12 * 10 = 120