Implemented in | Navigator 2.0, LiveWire 1.0 |
while (condition) {
statements
}
while
loop iterates as long as n
is less than three.n = 0Each iteration, the loop increments
x = 0
while(n < 3) {
n ++
x += n
}
n
and adds it to x
. Therefore, x
and n
take on the following values:![]() | After the first pass: n = 1 and x = 1 |
![]() | After the second pass: n = 2 and x = 3 |
![]() | After the third pass: n = 3 and x = 6 |
n < 3
is no longer true, so the loop terminates.
Last Updated: 10/31/97 12:29:59