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); } } }

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++; } } } }

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); } } }

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); } } }

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