C# : Program to print a table

In this C# tutorial we were showing printing of table of any number entered by the user. Here we are using "for" loop for our problem, you can also use while loop for the same. Aso, here we are taking three variables "num" for number, "i" for counter variable and "res" for result. Now, lets get started!!

using System;
​class table
{
 public static void Main(String []args)
 {
        int num,i,res=0;
        Console.WriteLine("Please enter number whose table you want to display : ");
        num=Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Your table is \n");
        for(i=0;i<=10;i++)
        {
         res=num*i;
         Console.WriteLine(num + "*" + i + "=" + res);
        }
 }
}
SHARE

Raunak Hajela

Hi. I’m CEO/Founder of Kodestat. I’m Student, Geek, Web Designer, Developer, Blog Enthusiast and Player. Inspired to make things looks better. I like playing with codes plus I am marvel fan :-P You can check my design portfolio here. For consulation fell free to drop an email at raunakhajela@gmail.com.

  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment