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

  1. // Score Rater
  2. // Demonstrates the if statement
  3.  
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. int main() 
  8. {
  9.     if (true)
  10.         cout << "This is always displayed.\n\n";
  11.  
  12.     if (false)
  13.         cout << "This is never displayed.\n\n";
  14.  
  15.     int score = 1000;
  16.  
  17.     if (score)
  18.         cout << "Okay, at least you didn't score zero.\n\n";
  19.     
  20.     if (score > 500)
  21.         cout << "You scored over 500.  Nice.\n\n";
  22.  
  23.     if (score == 1000)
  24.     {
  25.         cout << "You scored a perfect 1000!\n";
  26.         cout << "Now that's impressive.\n\n";
  27.     }
  28.  
  29.     if (score > 500)
  30.     {
  31.         cout << "You scored at least 500.\n";
  32.         if (score >= 1000)
  33.             cout << "You scored 1000 or more!\n";
  34.     }
  35.  
  36.     return 0;
  37. }
  38.  
  39.