Logical Operators in C++

Notes:

Logical Operators in C++ Programming Language:
Logical operators are also known as logical connectives. They are used to connect one or more relational expressions (or conditional expressions). They accept Boolean operands i.e. true or false, on evaluation they yield the result either true (1) or false (0)

Note: zero indicates false and any non zero value indicates true

- There are 3 logical operators available in C++. They are

&&: Logical And Operator:
If both LHS and RHS operands are true then the result will be true, in all other cases the result will be false

||: Logical Or Operator:
If both LHS and RHS operands are false then the result will be false, in all other cases the result will be true

!: Logical Not Operator:
If the given operand is false, then the result will be true. Vice versa

Example Code:
#include <iostream>
using namespace std;

int main()
{
cout << ((3<4) && (4<5)) << endl; // 1
cout << ((3<4) && (4>5)) << endl; // 0
cout << ((3>4) && (4<5)) << endl; // 0
cout << ((3>4) && (4>5)) << endl; // 0
cout << endl;
cout << ((3<4) || (4<5)) << endl; // 1
cout << ((3<4) || (4>5)) << endl; // 1
cout << ((3>4) || (4<5)) << endl; // 1
cout << ((3>4) || (4>5)) << endl; // 0
cout << endl;
cout << !(3<4) << endl; // 0
cout << !(3>4) << endl; // 1
cout << endl;
cout << !1 << endl; // 0
cout << !10 << endl; // 0
cout << !-10 << endl; // 0
cout << !0 << endl; // 1

return 0;
}