FANDOM


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 loopsEdit

Curly bracket programming languages Edit

int x = 0;
int y = 10;

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

Language: Pascal Edit

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

PHPEdit

$i=0;

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

Or:

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

Visual BasicEdit

Do While x < y
    ' Do something
Loop

Or:

While x < y
    ' Do something
End While

See Also Edit

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

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.