Range of numbers
Last updated:
8/22/2020
⁃
Difficulty:
Easy
Create a C# program that requests a range of numbers from the user (x, y) and displays them on the screen.
Input
1
10
Output
1 2 3 4 5 6 7 8 9 10
Solution
using System;
public class RangeOfNumbers
{
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++)
{
Console.Write("{0} ", i);
}
}
}