One kind of loop is called a
while loop. In plain English, this translates to "While such-and-such is true, do the following." Figure 8-7 shows a
while loop that prints the word happy three times.
Figure 8-7. Printing the word happy three times with a
Loops are a very common programming technique. They may seem strange the first couple of times you see them, but they are so common that after a while you'll understand them on sight.
while loop starts with a variable set to zero, as in ❶ of Figure 8-7. The variable
index is just like any other variable.
Once you've set this variable, the
while loop begins. Line ❷ reads, ...