Week 5 In-Class Examples
#include <iostream>
using namespace std;

int main (void) {

   int an_integer = 0;

   cout << "Please enter an integer between 0 and 10 :\n";
   cin >> an_integer;

   if (an_integer == 5) {
     cout << "You guessed correctly!!\n";
     cout << "Good Job...\n";
   } else {
     cout << "Sorry, you guessed wrong\n";
   }

   return 0;
}


#include <iostream>
using namespace std;

int main (void) {

   int an_integer = 0;

   cout << "Please enter an integer between 0 and 10 :\n";
   cin >> an_integer;

   if ( (an_integer > 10) ||(an_integer < 0) ) {
      cout << "Out of range\n";
   } else {
      if (an_integer == 5) {
        cout << "You guessed correctly!!\n";
        cout << "Good Job...\n";
      } else {
        cout << "Sorry, you guessed wrong\n";
      } // end of the inner if
   }
   return 0;
} // end of main function

#include <iostream>
using namespace std;

int main (void) {

   int an_integer = 0;

   cout << "Please enter an integer between 0 and 10 :\n";
   cin >> an_integer;

   switch (an_integer) {
     case 5:
       cout << "You guessed correctly\n";
       break;
     case 4:
     case 6:
       cout << "You are close\n";
       break;
     default:
       cout << "You are wrong.\n";

   }

   return 0;
} // end of main function