2012-10-23, 05:17 PM
Imagine Wrote:I know for loops, it's just that I prefer to use standard while loops.
That's a matter of personal taste, I suppose. 'for' is just as standard as 'while'.
Personally I prefer to use 'for' when the loop is a basic progression from 0 to N-1, because it is clear at a glance that that is what the loop does.
When you write "while (i < N)" it implies, to me, that there is some more complicated logic to i. That depending on the logic inside the loop, i might go back, or skip forward more than one, for example.
(Of course, the language doesn't enforce either. I've seen some pretty crazy code in 'for' loops.)

