while
- Last UpdatedApr 24, 2024
- 1 minute read
The while statement executes its body while a specified Boolean logical operators evaluates to true. The expression is evaluated before each execution of the loop. A while loop executes zero or more times.
Example code
static void testWhile()
{
int j=0;
while (j < 12)
{
Runtime::Environment.Print("j=" + j);
j = j + 1;
}
}
//Output:
//j=0
//j=1
//j=2
//j=3
//j=4
//j=5
//j=6
//j=7
//j=8
//j=9
//j=10
//j=11