In this C++ tutorial, you will learn about NOT Logical operator, its truth table, and how to use NOT logical operator with boolean values, with example programs.

C NOT Logical Operator

C++ NOT Logical Operator is used to inverse the result of a boolean condition. ! is the symbol used for NOT logical Operator.

NOT logical Operator takes only one boolean value as operand and returns a boolean value.

!operand

Truth Table

Following is the truth table of NOT Logical Operator.

Operand Returns
true 0
false 1

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.