home *** CD-ROM | disk | FTP | other *** search
/ Beginning C++ Through Gam…rogramming (2nd Edition) / BCGP2E.ISO / source / chapter02 / finicky_counter.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2003-10-21  |  363 b   |  26 lines

  1. // Finicky Counter
  2. // Demonstrates break and continue statements
  3.  
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. int main() 
  8. {
  9.     int count = 0;
  10.     while (true)
  11.     {
  12.         count += 1;
  13.  
  14.         //end loop if count is greater than 10
  15.         if (count > 10)
  16.             break;
  17.  
  18.         //skip the number 5
  19.         if (count == 5)
  20.             continue;
  21.  
  22.         cout << count << endl;
  23.     }
  24.  
  25.     return 0;
  26. }