C Program to Display Multiplication Table

Last Updated:

Using for Loop

In the following example, we will create and display the Multiplication Table for the given number (9) using for loop

Example

C Compiler
#include <stdio.h> int main() { int table = 9; int length = 10; int i = 1; printf("Multiplication table: %d", table); for(i=1; i<=length; i++) printf("\n%d * %d = %d", i, table, i * table); return 0; }

Using while Loop

In the following example, we will create and display the Multiplication Table for the given number (9) using while loop

Example

C Compiler
#include <stdio.h> int main() { int table = 9; int length = 10; int i = 1; printf("Multiplication table: %d", table); while(i <= length){ printf("\n%d * %d = %d", i, table, i * table); i++; } return 0; }

Using do while Loop

In the following example, we will create and display the Multiplication Table for the given number (9) using do while loop

Example

C Compiler
#include <stdio.h> int main() { int table = 9; int length = 10; int i = 1; printf("Multiplication table: %d", table); do{ printf("\n%d * %d = %d", i, table, i * table); i++; }while(i <= length); return 0; }

Display Customized Table

In the following example, we will display the table according to the given table number and table length.

Example

C Compiler
#include <stdio.h> int main() { int table, length; int i = 1; printf("Enter the table number: "); scanf("%d", &table); printf("Enter the length: "); scanf("%d", &length); printf("\nMultiplication table: %d", table); for(i=1; i<=length; i++) printf("\n%d * %d = %d", i, table, i * table); return 0; }

Share this Page

Meet the Author