Quote Originally Posted by petes1234
... I've been taught to always have the condition check at the top of the loop (though to be honest, I'm not sure why,... probably easier to read).
In purely practical terms, the idea is that you put the loop condition at the start if the loop can have zero or more iterations, and you put it at the end if there must always be at least one iteration. This way the code structure explicitly mirrors the requirement.

Having said that, the vast majority of the code I see uses the 'for' loop whatever the situation... it seems that most coders find it easier to follow if the same control structure is used for every loop rather than changing the control structure to reflect the flow.

The key to performance is elegance, not batallions of special cases...
J. Bently & D. McIlroy