Hello, I’m working on this task:
Read an integer count from the console. Then create an array of integers of size count. The value of every cell should be its index value. Output every cell of the array to the screen, each from the new line, starting from the cell with index 0. For example:
>4
0
1
2
3
Here is my code:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter an integer count: ");
int count = int.Parse(Console.ReadLine());
int[] array = new int[count];
for (int i = 0; i < count; i++)
{
array[i] = i;
}
foreach (int value in array)
{
Console.WriteLine(value);
}
}
}
Can anyone please help me to solve it?