init;
while (test) {
statements;
step;
}
I had a question about the location of the step in the above while loop. Does it matter where the step is written? In other words does it change the any of the values in the while loop if the step is written as the first statement or somewhere in the middle or at the end? If it does can you provide a short example to illustrate that effect.
The placement of the step could definitely influence the body of the loop. Imagine if the code below were accessing an array, the first example could miss the first element in an array.
This outputs 0-9
This outputs 1-10