Why does a for-loop stop at the correct place when you use the same counter name as your upper limit?
1 view (last 30 days)
Ahmet Cecen on 24 Apr 2018
Because the upper limit is evaluated at the beginning of the execution when r = 7. If you want the loop condition to be evaluated every time the loop iterates, you need to use a while loop. See even if you did something like this:
You would still get 7 iterations. However now we are overwriting the iterator so you would only get 5s.