Sania Syed wrote:I am trying to understand for loops...
There is another advantage of
for loops, and that is that their syntax allows you to define variables
entirely within the scope of the loop itself; so, for example, your loop could have (and probably should have) been written:
and that's why I generally prefer them - sometimes even in cases where others might write a
while loop.
Winston