doWhile

Syntax

do{ 
   statements 
} 
while (conditions);

Details

The do-while loop first executes the do statement, then checks the condition at the bottom of the loop. This guarantees the loop is executed at least once. "while" cannot be used in the beginning of a statement. Both parentheses () after while and braces { } after do are mandatory for do-while statements.

Examples

x=1
do {x+=2} while(x<100)
x;
// output
101

x=1
y=0
do {x+=y; y+=1} while(x<100 and y<10);
x;
// output
46
y;
// output
10