Includes a logical operator in if to determine whether the age is greater than 10 and less than 100. - C++ Statement

C++ examples for Statement:if

Description

Includes a logical operator in if to determine whether the age is greater than 10 and less than 100.

Demo Code

#include <iostream>
using namespace std;
int main()//from www . j av a2s .c om
{
   int age;
   cout << "What is your age? ";
   cin >> age;
   if ((age < 10) || (age > 100))
   {
      cout << " \x07 \x07 \n";   // Beep twice
      cout << "*** The age must be between 10 and 100 ***\n"; }
      else
      {
         cout << "You entered a valid age.";
      }
      return 0;
}

Result


Related Tutorials