Loading...

How to make a Table Generator in C# with upper and lower limit

Making a Table Generator in C# for loop:

Making a table generator in C# with user defined Upper limit and Lower limit using For Loop is not a big task, It is simple and easy that you will learn easily through code. To do this we will ask user the number to generate the table of, the upper limit and the lower limit and will generate the table using for loop.

Code:

              class Program
           {
             static void Main(string[] args)
            {
            Console.WriteLine("Please enter the number whose table you wish to display");
            int num = Convert.ToInt32(Console.ReadLine());  // taking number of whoch table will be generated
            Console.WriteLine("Please enter the upper limit:");
            int upper = Convert.ToInt32(Console.ReadLine());  // taking upper limit
            Console.WriteLine("Please Enter the lower limit:");
            int lower=Convert.ToInt32(Console.ReadLine());  // taking lower limit
            for (int i = lower; i <= upper; i++)
                {
                Console.WriteLine("{0}\t*\t{1}\t=\t{2}",num,i,(num*i)); // the logic is number multibly by i, which will go through lower limit to upper limit
                }
             }
           }

Output:



Hit Like Button if you understood, It helps a lot to keep us Motivated.

0 comments:

Post a Comment

Google+

 
TOP