Syntax:
while(Var1 OP Var2)
{
Statement1;
Statement2;
...
}
Where,
Var1 - The first variable to
compare
OP - The conditional
operator
Var2 - The second variable to compare
Description:
Processes the statements within the brackets while
the conditional statement is true. When the conditional statement
is checked and is not true, the interpreter exits the while loop and
continues after the closing bracket. The conditional statement
is checked prior to processing any statements within the while loop.
Example
Code |
int
i = 0;
while(i < 5){
disp("i is " + string(i));
i = i + 1;
} |
Output |
i is
0
i is 1
i is 2
i is 3
i is 4 |
See Also: for,
if-else, Conditional
Statements