- Course
- Flow controls B
- Infinite multiplication tables
Infinite multiplication tables
Last updated:
8/22/2020
⁃
Difficulty:
Easy
Create a C# program that asks the user for a range of numbers (x, y) and displays the multiplication tables from x to y.
Input
2
3
Output
2x1= 2
2x2= 4
2x3= 6
2x4= 8
2x5= 10
2x6= 12
2x7= 14
2x8= 16
2x9= 18
2x10= 20
3x1= 3
3x2= 6
3x3= 9
3x4= 12
3x5= 15
3x6= 18
3x7= 21
3x8= 24
3x9= 27
3x10= 30
Solution
using System;
public class InfiniteMultiplicationTable
{
public static void Main(string[] args)
{
int x = Convert.ToInt32(Console.ReadLine());
int y = Convert.ToInt32(Console.ReadLine());
for (int i = x; i <= y; i++)
{
for (int j = 1; j <= 10; j++)
{
Console.WriteLine("{0}x{1}= {2}", i, j, i * j);
}
Console.WriteLine();
}
}
}