Use block of statements in if, Prints a message depending on years of service. - C++ Statement

C++ examples for Statement:if

Description

Use block of statements in if, Prints a message depending on years of service.

Demo Code

#include <iostream>
using namespace std;
int main()// w w  w  .j  a v a  2 s. c om
{
   int yrs;
   cout << "How many years of service? ";
   cin >> yrs;   // Determine the years they have worked.
   if (yrs > 20)
   {
      cout << "Give a gold watch\n";
   }
   else
   {
      if (yrs > 10)
      {
         cout << "Give a paper weight\n";
      }
      else
      {
         cout << "Give a pat on the back\n";
      }
   }
   return 0;
}

Result


Related Tutorials