C++ NOT Logical Operator
C++ NOT Logical Operator is used to inverse the result of a boolean condition. !
is the symbol used for C++ NOT Operator.
C++ NOT Operator takes only one boolean value as operand and returns a boolean value.
!operand
Truth Table
Following is the truth table of C++ NOT Logical Operator.
Operand | Returns |
true | 0 |
false | 1 |
C++ NOT Example
Following example demonstrates the usage of NOT logical operator (!) with different boolean values.
main.cpp
#include <iostream> using namespace std; int main() { cout << (!true) << endl; cout << (!false) << endl; }
Output
0 1
Conclusion
In this C++ Tutorial, we learned what C++ NOT Logical Operator is, and how to use it with conditional expressions.