C# Program to Print Multiplication Table

This is a C# Program to find and display the multiplication table.

Problem Description

This C# Program Finds and displays the Multiplication Table.

Problem Solution

Here the limit is obtained from the user and the multiplication table is diaplayed.

Program/Source Code

Here is source code of the C# Program to Find and display the Multiplication Table. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

/*
 * C# Program to Find and display the Multiplication Table
 */
using System;
class Multipication
{
    static void Main()
    {
        int no;
 
        Console.Write("Enter a no : ");
        no = Convert.ToInt32(Console.ReadLine());
        while (no <= 0)
        {
            Console.WriteLine("You entered an invalid no");
 
            Console.Write("Enter a no great than 0: ");
            no = Convert.ToInt32(Console.ReadLine());
        }
        Console.WriteLine("Multiplication Table :");
        for (int i = 1; i <= no; i++)
        {
            Console.WriteLine("\n");
 
            for (int j = 1; j <= no; j++)
            {
                Console.Write("{0,6}", i * j);
            }
 
        }
        Console.Read();
    }
}
Program Explanation

This C# program we are reading the limit to print the multiplication table by using ‘no’ variable. Using for loop compute the multiplication table till the value of ‘no’ variable. Print the multiplication table.

advertisement
advertisement
Runtime Test Cases
 
Enter a No : 5
Multiplication Table :
 1  2  3  4  5
 2  4  6  8  10
 3  6  9  12  15
 4  8  12  16  20
 5  10  15  20  25

Sanfoundry Global Education & Learning Series – 1000 C# Programs.

If you wish to look at all C# Programming examples, go to 1000 C# Programs.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.