NXC  Version 1.2.1 r5
 All Data Structures Files Functions Variables Groups Pages
The while statement

The while statement is used to construct a conditional loop.

The condition is evaluated, and if true the body of the loop is executed, then the condition is tested again. This process continues until the condition becomes false (or a break statement is executed). The syntax for a while loop appears in the code fragment below.

while (condition) body

Because the body of a while statement must be a single statement, it is very common to use a compound statement as the body. The sample below illustrates this usage pattern.

while(x < 10)
x = x+1;
y = y*2;