Saturday, April 9, 2016

Switch and Boolean Statement in C++

Here is a sample program that I wrote a long time ago that demonstrate the use of switch and Boolean statements in C++ language that will check if the age of the person is still a minor or adult already.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.


Program Listing


#include <iostream>

using namespace std;

main()
{
      int a=0;
      
      cout << "Enter a your age : ";
      cin >> a;
      
      switch(a >= 18 ? true : false)
      {
               case true : cout << "Your are Adult.";
                                break;
               case false  : cout << "Sorry you are still Minor.";
         }
      cout << "\n\n";
      system("pause");
      }
      




No comments:

Post a Comment