Technology
 

Do while loop

From Programmer's Wiki

(Redirected from Do While loop)

A do-while loop is a loop which executes at least once and will only terminate when the Boolean expression (or "condition") returns false. The do-while loop is not as popular as the while loop because any references inside it which depend on the condition being true must be usable before the condition is checked. The do-while loop is often used when some preparation is needed before iteration.


[edit] Curly bracket programming languages

int x = 0;
int y = 10;

do{
    x++;
}while(x < y);

[edit] Visual Basic

Dim x As Integer = 0
Dim y As Integer = 10

Do
    x += 1
Loop While x < y


[edit] Python

Python does not have a Do-while loop so if you want to use one you have to be a bit tricky.

while True:
    do_something()
    if condition():
        break

[1]

Control structures
If statement - Switch statement - While loop - For loop - For Each loop - Do while loop