C++ examples for Operator:Logical Operator
Testing a Person's Age use "and" operator (&&).
#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; }