The WHILE statement:

while ( Boolean Expression )
   Embedded Statement

The do while statement:

do
  Embedded Statement
while ( Boolean Expression ) ;

Below is a flowchart of the While loop.


Example:

#include <iostream.h>

int main() {
   char draw;                // the user will choose this

   do {
      cout << "\nType in a character, ";
      cout << "then press the RETURN/ENTER key!  ";
      cin >> draw;

      if (draw != `0') {
         cout << "\n\n";
         cout << "    " << draw << "      " << draw << `\n';
         cout << "    " << draw << draw << draw << "    "
                        << draw << draw << draw << `\n';
         cout << "   " << draw << draw << draw << draw << draw << "  "
                       << draw << draw << draw << draw << draw << `\n';
      }
      else cout << "\nSentinel value 0 encountered";
   } while (draw != `0');
   cout << " - program terminated\n\n";

   return(0);
}