---
title: "3.12 Logical NOT Operator (!)"
description: "The logical NOT operator (`!`) is a unary operator that reverses the logical value of its operand. If the operand evaluates to `true`, the result is `false`. If the operand evaluates to `false`, the result is `true`. The logical NOT…"
url: "https://edcret.in/docs/cpp-programming/operators-cplusplus/3-12-logical-not-operator/"
updated: "2026-07-28"
category: C++ Programming / Operators
---

# 3.12 Logical NOT Operator (!)

The logical NOT operator (`!`) is a unary operator that reverses the logical value of its operand. If the operand evaluates to `true`, the result is `false`. If the operand evaluates to `false`, the result is `true`.

The logical NOT operator is commonly used to test whether a condition is not satisfied or to invert the value of a Boolean expression.

## Source Code

```
#include <iostream>

int main()
{
    bool is_logged_in = false;

    std::cout << "Original Value : " << is_logged_in << '\n';
    std::cout << "Negated Value  : " << !is_logged_in << '\n';

    return 0;
}
```

## Output

```
Original Value : 0
Negated Value  : 1
```

## Explanation

- The logical NOT operator (`!`) is a unary operator that operates on a single operand.
- It reverses the logical value of its operand.
- If the operand is `true`, the result becomes `false`.
- If the operand is `false`, the result becomes `true`.
- `!is_logged_in` evaluates to the opposite of the value stored in `is_logged_in`.
- The logical NOT operator does not modify the original variable; it only produces the negated result of the expression.
- By default, `std::cout` displays Boolean values as `1` for `true` and `0` for `false`.
- `return 0;` terminates the program successfully.
