In many computer programming languages, a do while loop is a control flow statement that executes a block of code and then either repeats the block or exits the loop depending on a given boolean condition.
This means that the code is always executed first and then the expression or test condition is evaluated.
A do-while loop provides for the action's ongoing execution until the condition is no longer true.
For example, the Pascal and Lua languages have a "repeat until" loop, which continues to run until the control expression is true and then terminates.
As long as the continue statement is not used, the above is technically equivalent to the following (though these examples are not typical or modern style used in everyday computers): or These example programs calculate the factorial of 5 using their respective languages' syntax for a do-while loop.
It makes a semicolon needed after the macro, providing a more function-like appearance for simple parsers and programmers as well as avoiding the scoping problem with if.
It is recommended in CERT C Coding Standard rule PRE10-C.[1] With legacy Fortran 77 there is no DO-WHILE construct but the same effect can be achieved with GOTO: Fortran 90 and later supports a DO-While construct: Pascal uses repeat/until syntax instead of do while.