using System;
namespace Console_Table
{
class table
{
int i=1,count;
public void dispTable() //using "do-while loop"
{
Console.Write("Enter the number for table : ");
int inputnum1 = int.Parse(Console.ReadLine());
Console.Write("Enter the number up to which you want to see the table :");
int inputnum2 = int.Parse(Console.ReadLine());
do
{
count = inputnum1 * i;
i++;
Console.WriteLine(count);
} while (i <= inputnum2);
}
//public void dispTable() //using "For loop"
//{
// Console.WriteLine("Enter the number for table :");
// int inputnum1 = int.Parse(Console.ReadLine());
// Console.WriteLine("Enter the number upto which you want to see the table :");
// int inputnum2 = int.Parse(Console.ReadLine());
// Console.WriteLine("_________________________________________________________");
// Console.WriteLine("Table Number {0} :", inputnum1);
// for (i = 1; i <= inputnum2; i++)
// {
// count = inputnum1 * i;
// Console.WriteLine("\t\t\t{0} * {1} = {2} ",inputnum1,i,count );
// }
// Console.WriteLine("_________________________________________________________");
//}
//public void dispTable() //using "While-loop"
//{
// Console.WriteLine("Enter the number for table :");
// int inputnum1 = int.Parse(Console.ReadLine());
// Console.WriteLine("Enter the number upto which you want to see the table :");
// int inputnum2 = int.Parse(Console.ReadLine());
// while (i <= inputnum2)
// {
// count = inputnum1 * i;
// Console.WriteLine("{0} * {1} = {2}", inputnum1, i, count);
// i++;
// }
//}
static void Main(string[] args)
{
table t = new table();
t.dispTable();
Console.ReadKey();
}
}
}
No comments:
Post a Comment