You are on page 1of 1

class Program

{
static void Main(string[] args)
{
Console.WriteLine("Enter 2 numbers:");
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());

var myArr = ConsecutiveNumbers(a, b);

for (int i = 0; i < myArr.Length; i++)


Console.Write(myArr[i] + " ");
}

static int[] ConsecutiveNumbers(int first, int second)


{
int count = 0;
int n = first;

while(n <= second)


{
count++;
n++;
}
int[] arr = new int[count];

n = first;
for(int i = 0; i < count; i++)
{
arr[i] = n;
n++;
}

return arr;
}
}

You might also like