Wednesday, 27 July 2016

Several Multiplication Tables

Display a range of multiplication tables, as long as the user asks for... The first input is the start of the range and the second number is the end. For example if you input 2 and then 6, the computer will display the multiplication tables of 2, 3, 4, 5 and 6. The third number represents how many numbers you want in each table. f\or example if you then put the third number as 7, the computer will display the tables from 2 to 6 and the table will go from 2x1 to 2x7 then move on to 3x1 etc.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Multiplication
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter your start point of the table ");
            int number = int.Parse(Console.ReadLine());
           
            Console.WriteLine("Enter your end point of the table  ");
            int  amount   = int.Parse(Console.ReadLine());

            Console.WriteLine("till what number each table to show");
            int length = int.Parse(Console.ReadLine());

            int n = number;
            int x = 1;
            int a = 1;

            while (number <= amount)
            {
                while ( x <= length)
                {
                    Console.WriteLine("{0} x {1} = {2}", number, x, x*number);
                   
                    x += 1;
                }

                number += 1;
                x = 1;

            }
            Console.ReadLine();
        }
    }
}


No comments:

Post a Comment