Testing a Person's Age use "and" operator (&&). - C++ Operator

C++ examples for Operator:Logical Operator

Description

Testing a Person's Age use "and" operator (&&).

Demo Code

#include <iostream>
using namespace std;
int main() {//w  w  w .j a  v  a  2 s  .  c  o  m
   int  n;
   cout << "Enter an age and press ENTER: ";
   cin >> n;
   if (n > 12 && n < 20) {
      cout << "Subject is a teenager." << endl;
   } else {
      cout << "Subject is not a teenager." << endl;
   }
   return 0;
}

Result


Related Tutorials