the factorial of 5 using their respective languages' syntax for a do-while loop. ActionScript 3 var counter: int = 5; var factorial: int = 1; do { factorial *= counter--; /* Multiply, then decrement. */ } while (counter > 0); trace(factorial); Ada with Ada.Integer_Text_IO; procedure Factorial is Counter : Integer := 5; Factorial : Integer := 1; begin loop Factorial := Factorial * Counter; Counter := Counter - 1; exit when Counter = 0; end loop; Ada.Integer_Text_IO.Put (Factorial); end Factorial; BASIC Early BASICs (such as GW-BASIC) used the syntax WHILE/WEND. Modern BASICs such as PowerBASIC provide both WHILE/WEND and DO/LOOP structures, with syntax such as DO WHILE/LOOP, DO UNTIL/LOOP, DO/LOOP WHILE, DO/LOOP UNTIL, and DO/LOOP (without outer testing, but with a conditional EXIT LOOP somewhere inside the loop). Typical BASIC source code: Dim factorial As Integer Dim counter As Integer factorial = 1 counter = 5 Do factorial = factorial * counter counter = counter - 1 Loop While counter > 0 Print factorial C# int counter = 5; int factorial = 1; do { factorial *= counter--; /* Multiply, then decrement. */ } while (counter > 0); System.Console.WriteLine(factorial); C int counter = 5; int factorial = 1; do { factorial *= counter--; /* Multiply, then decrement. */ } while (counter > 0); printf("factorial of 5 is %d\n", factorial); Do-while(0) statements are also commonly used in C macros as a way to wrap multiple statements into a regular (as opposed to compound) statement. 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 . It is recommended in CERT C Coding Standard rule PRE10-C. C++ int counter = 5; int factorial = 1; do { factorial *= counter--; } while (counter > 0); std::cout << "factorial of 5 is "<< factorial << std::endl; CFScript factorial = 1; count = 10; do { factorial *= count--; } while (count > 1); writeOutput(factorial); D int counter = 5; int factorial = 1; do { factorial *= counter--; // Multiply, then decrement. } while (counter > 0); writeln("factorial of 5 is ", factorial); Fortran With legacy FORTRAN 77 there is no DO-WHILE construct but the same effect can be achieved with GOTO: INTEGER CNT,FACT CNT=5 FACT=1 1 CONTINUE FACT=FACT*CNT CNT=CNT-1 IF (CNT.GT.0) GOTO 1 PRINT*,FACT END Fortran 90 and later does not have a do-while construct either,