C# program to print table for given number


Following program shows you how to print table for given number.
In this program we get number from user and print that number table using for loop

using System;

class MainClass {
  public static void Main (string[] args) {
    Console.WriteLine("Enter the number:");
    int input = Convert.ToInt32(Console.ReadLine());
    for (int i = 1; i <= 10; i++) {
      Console.WriteLine(input + " * " + i + " = " + input * i);
    }
  }
}

Output:

Enter the number:
 4
4 * 1 = 4
4 * 2 = 8
4 * 3 = 12
4 * 4 = 16
4 * 5 = 20
4 * 6 = 24
4 * 7 = 28
4 * 8 = 32
4 * 9 = 36
4 * 10 = 40