Hello everyone
Does anyone know how I can turn around an array?
The array is {10, 20, 30, 50}, and it need to be {50, 40, 30, 20, 10} printed in the serial monitor
Hello everyone
Does anyone know how I can turn around an array?
The array is {10, 20, 30, 50}, and it need to be {50, 40, 30, 20, 10} printed in the serial monitor
Your example is borked, but...
for (int i = 4; i >= 0; i--)
{
Serial.print(array[i]);
}
for (int i = 4-1; i >= 0; i--)
gcjr:
for (int i = 4-1; i >= 0; i--)
Depends. The OP borked their example. I took the desired output (of 5 elements) to be the correct representation...
{50, 40, 30, 20, 10}
I assumed they had missed out the 40 value from their source array.
Could be either, I grant you.