while [C++ Reference]
Keywords: keywords,while
Date: 2008-10-14T15:42:05-0700

## while

Syntax:

        while( condition ) {
        statement-list;
        }

The while keyword is used as a looping construct that will evaluate the statement-list as long as condition is true. Note that if the condition starts off as false, the statement-list will never be executed. (You can use a do loop to guarantee that the statement-list will be executed at least once.) For example:

         bool done = false;
         while( !done ) {
           ProcessData();
           if( StopLooping() ) {
             done = true;
           }
         }

Related Topics: break, continue, do, for, if