21 January 2014

C# program to print multiplication table

using System;

namespace SamplePrograms
{
    class NumberTable
    {
        public static void Main()
        {
            Console.WriteLine("For which number do you want to print multiplication table");
            int Number = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("What is your target? 10, 20, 30 etc...");
            int Target = Convert.ToInt32(Console.ReadLine());
            for (int i = 1; i <= Target; i++)
            {
                int Result = Number * i;
                Console.WriteLine(Number.ToString() + " X " + i.ToString() +
                                  " = " + Result.ToString());
            }
        }
    }
}

No comments:

Post a Comment