Information Technology Reference
In-Depth Information
The do Loop
The
do
loop is a simple loop construct in which the test expression is performed at the bottom
of the loop. The syntax for the
do
loop is shown here and illustrated in Figure 9-7.
Firs ,
Statement
is executed.
TestExpr
is then evaluated.
f
TestExpr
returns
true
, then
Statement
is executed again.
Each time
TestExpr
returns
true
,
Statement
is executed again.
When
TestExpr
returns
false
, control passes to the statement following the end of the
loop construct.
do
Statement
while(
TestExpr
); // End of do loop
Figure 9-7.
The do loop