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