Programmer's Wiki
16px-Pencil

The while loop is the most general type of loop, essentially a continuing if statement; it will execute while its Boolean expression (or "condition") is true. An infinite loop occurs when the condition never evaluates to false.

For more information see the Wikipedia article.

Examples of while loops[]

Curly bracket programming languages[]

int x = 0;
int y = 10;

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

Language: Pascal[]

while (x < y) do
begin
   {Do something.}
end;

PHP[]

$i=0;

while ($i<10) {
	// do something
	$i++;
}

Or:

while (true) {
	// do something
	if ($a==$b)
		break;
}

Visual Basic[]

Do While x < y
    ' Do something
Loop

Or:

While x < y
    ' Do something
End While

See Also[]

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