while Statement

while( expression )
statement

The while keyword executes statement repeatedly until expression becomes 0.

For more information, see do, for, break, and continue.

Example

This example copies characters from string2 to string1. If i is greater than or equal to 0, string2[i] is assigned to string1[i] and i is decremented. When i reaches or falls below 0, execution of the while statement terminates. 

// Example of the while statement
while ( i >= 0 ) 
{
    string1[i] = string2[i];
    i--;
}