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); } } }
0 comments:
Post a Comment