The && Operator (amplifier) : bool « Data Types « C++ Tutorial






#include <iostream>
using namespace std;
int main(void)
{
   int age;
   char choice;
   bool citizen;
   cout << "Enter your age: ";
   cin >> age;
   cout << "Are you a citizen (Y/N): ";
   cin >> choice;
   if (choice == 'Y')
      citizen = true;
   else
      citizen = false;
   if (age >= 18 && citizen == true)
      cout << "You are eligible to vote";
   else
      cout << "You are not eligible to vote";
   return 0;
}








2.6.bool
2.6.1.bool values
2.6.2.A bool value can control the if statement
2.6.3.Outcome of a relational operator is a true/false value
2.6.4.Variable size of bool
2.6.5.The || Operator
2.6.6.The !(Exclamation mark) Operator
2.6.7.The && Operator (amplifier)
2.6.8.Output boolean variable as boolean literal or number
2.6.9.Use bool value to control a while loop
2.6.10.Logical operators.