Technology
 

While loop

From Programmer's Wiki

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.

Contents

[edit] Examples of while loops

[edit] Curly bracket programming languages

int x = 0;
int y = 10;

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

[edit] Language: Pascal

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

[edit] PHP

$i=0;

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

Or:

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

[edit] Visual Basic

Do While x < y
    ' Do something
Loop

Or:

While x < y
    ' Do something
End While

[edit] See Also

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