While loop

From CodeCodex

The while loop is a common looping mechanism. It is comparable to the for loop.

Implementations[edit]

C / C++[edit]

int x = 0;
int y = 10;

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

Java[edit]

int x = 0;
int y = 10;

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

Pascal[edit]

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

PHP[edit]

$i=0;

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

Or:

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

Ruby[edit]

x = 10
while x > 0
  # do something
  x -= 1
end

Tcl[edit]

set x 10 while {$x > 0} {

    puts "x is $x"
    incr x -1

} </pre>

Visual Basic[edit]

Do While x < y
    ' Do something
Loop

Or:

While x < y
    ' Do something
End While