3.2.3 while

Previous Index Next


The while statement evaluates an expression and then executes a statement until the the expresion is false. The basic syntax is :
 
while ( Expression )
   StatementToExecute
For example:
int z=0;              // declare an integer z and initialize it to 0

while (  z < 100 )    // while z is less then 100
 {
   z = z + 10;        //   add 10 to z
 }

1