C# Program to Display Multiplication Table

You are Here:

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
using System; namespace myApp { class Program { static void Main(string[] args) { int table = 9; int length = 10; int i = 1; Console.WriteLine("Multiplication table: " +table); for(i=1; i<=length; i++) Console.WriteLine("{0, 2} * {1, 2} = {2}", i, table, i * table); } } }

Output

Multiplication table: 9 1 * 9 = 9 2 * 9 = 18 3 * 9 = 27 4 * 9 = 36 5 * 9 = 45 6 * 9 = 54 7 * 9 = 63 8 * 9 = 72 9 * 9 = 81 10 * 9 = 90

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
using System; namespace myApp { class Program { static void Main(string[] args) { int table = 9; int length = 10; int i = 1; Console.WriteLine("Multiplication table: " +table); while(i <= length) { Console.WriteLine("{0, 2} * {1, 2} = {2}", i, table, i * table); i++; } } } }

Output

Multiplication table: 9 1 * 9 = 9 2 * 9 = 18 3 * 9 = 27 4 * 9 = 36 5 * 9 = 45 6 * 9 = 54 7 * 9 = 63 8 * 9 = 72 9 * 9 = 81 10 * 9 = 90

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
using System; namespace myApp { class Program { static void Main(string[] args) { int table = 9; int length = 10; int i = 1; Console.WriteLine("Multiplication table: " +table); do{ Console.WriteLine("{0, 2} * {1, 2} = {2}", i, table, i * table); i++; }while(i <= length); } } }

Output

Multiplication table: 9 1 * 9 = 9 2 * 9 = 18 3 * 9 = 27 4 * 9 = 36 5 * 9 = 45 6 * 9 = 54 7 * 9 = 63 8 * 9 = 72 9 * 9 = 81 10 * 9 = 90

Display Customized Table

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

Example

C# Compiler
using System; namespace myApp { class Program { static void Main(string[] args) { int table, length, i; Console.Write("Enter the table number: "); table = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter the length: "); length = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("\nMultiplication table: " +table); for(i=1; i<=length; i++) Console.WriteLine("{0, 2} * {1, 2} = {2}", i, table, i * table); } } }

Output

Enter the table number: 5 Enter the length: 10 Multiplication table: 5 1 * 5 = 5 2 * 5 = 10 3 * 5 = 15 4 * 5 = 20 5 * 5 = 25 6 * 5 = 30 7 * 5 = 35 8 * 5 = 40 9 * 5 = 45 10 * 5 = 50

Reminder

Hi Developers, we almost covered 90% of String functions and Interview Question on C# with examples for quick and easy learning.

We are working to cover every Single Concept in C#.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author