do Keyword

Keyword Index

Do-while loop.

Keyword do is usually used together with while to make another form of repeating statement. Such form of the loop uses the following syntax:

do statement while (expression)
statement, which is usually a compound statement, is executed repeatedly as long as the value of expression remains non-zero. The test takes place after each execution of the statement. For example,
i = 1; n = 1;
do
  {
    n *= i;
    i++;
  } while (i <= factorial);