Do while loops

A do while loop is very much the same as while loops with the exception that a do while loop evaluates its expression after the body. This means that a do while loop will always execute at least once before checking the loop condition

int x= 10000000;// Ten million
do{
   x++;
}while(x < 10);
// x now = 10000001 

The code will execute the contents of the do block (x++), once, before the while condition is tested even though the condition evaluates to false.

Note

Note that break can also be used in do while loops.

Let's look at one more type of loop before we get back to the game.