do while loops

The do while loop is very similar to the while loop, however the condition isn't checked till the bottom of the loop, meaning the loop with always execute at least once.

The syntax is:

do
  statement;
while (expression);

or

do {
  statement;
  ...
} while (expression);

The first form is probably of dubious value b/c it is too easy to confuse with:

statement;
while (expression);

Which is quite different.

See also the summary of loops .


Tim Hollebeek

Beek @ZorkMUD, Lima Bean, IdeaExchange, TMI-2, and elsewhere