In this C# program, we will learn how to write a program to take a number as input and print its multiplication table.
Here is the code of the program to take a number as input and print its multiplication table:
using System;
namespace Tutorialsrack
{
class Program
{
/* C# Program to Take Number as Input and Print its Multiplication Table */
static void Main(string[] args)
{
int num,product;
Console.Write("Enter the Number to Print its Multiplication Table: ");
num = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\nMultiplication Table For {0}: ",num);
for(int i = 1; i <= 10; i++)
{
product = num * i;
Console.WriteLine("{0} x {1} = {2}",num,i,product);
}
//Hit ENTER to exit the program
Console.ReadKey();
}
}
}
Enter the Number to Print its Multiplication Table: 9
Multiplication Table For 9:
9 x 1 = 9
9 x 2 = 18
9 x 3 = 27
9 x 4 = 36
9 x 5 = 45
9 x 6 = 54
9 x 7 = 63
9 x 8 = 72
9 x 9 = 81
9 x 10 = 90
Comments