Logical operator keywords: and, or, not, not_eq : relational and logical operators « Operators statements « C++ Tutorial






#include <iostream>
using std::boolalpha;
using std::cout;
using std::endl;

int main()
{
   bool a = true;
   bool b = false;
   int c = 2;
   int d = 3;

   cout << boolalpha;

   cout << "a = " << a << "; b = " << b
      << "; c = " << c << "; d = " << d;

   cout << "\n\nLogical operator keywords:";
   cout << "\n   a and a: " << ( a and a );
   cout << "\n   a and b: " << ( a and b );
   cout << "\n    a or a: " << ( a or a );
   cout << "\n    a or b: " << ( a or b );
   cout << "\n     not a: " << ( not a );
   cout << "\n     not b: " << ( not b );
   cout << "\na not_eq b: " << ( a not_eq b );

   return 0;
}
a = true; b = false; c = 2; d = 3

Logical operator keywords:
   a and a: true
   a and b: false
    a or a: true
    a or b: true
     not a: false
     not b: true
a not_eq b: true








3.2.relational and logical operators
3.2.1.The relational and logical operators
3.2.2.Use And operator to connect two boolean expressions
3.2.3.Logical operator keywords: and, or, not, not_eq
3.2.4.Create an XOR using the C++ logical operators.
3.2.5.Output the results of several variable comparisons.
3.2.6.A Demonstration of Branching Based on Relational Operators