
Control Structures 317
11.13 THE while LOOP
Another kind of loop structure in C/C++ is the while
loop. It’s format is given below.
Syntax:
while (test condition)
{
body of the loop
}
The test condition may be any expression. The loop state-
ments will be executed till the condition is true i.e., the
test condition is evaluated and if the condition is true,
then the body of the loop is executed. When the condi-
tion becomes false the execution will be out of the loop.
The execution of the loop is shown in Figure 11.4.
The block of the loop may contain single state ment
or a number of statements. The same block can be
repeated. The braces are needed ...