while


while is another type of loop. while will run a block of code over and over until a condition becomes false. Syntax:

while(condition)
{
   // run code
}

Here's a working example:

while(i < var2) i=i+1;