+ 1
Using arrays display the numbers in reverse order.
how can I solve it
4 Respostas
+ 3
Actually, I would use:
for (int i = array.length - 1; i >= 0; i--)
{
Console.WriteLine(array[i]);
}
Robert's code will generate an error as array.length is 5 and there is no element with index 5.The 1st element has index 0, second has index 1 and so on. In general, last element in an array has index array.length - 1
+ 2
you should do it with a for loop
int[] array = new int {1,2,3,4,5};
for(int i = array.length; i > 0; i--)
{
Console.WriteLine(array[i]);
}
+ 2
thank you
+ 1
yep miss that one. Not reversing a lot of array tó be honest