---
title: 3.12 Logical NOT
description: "The logical NOT operator `!` reverses the logical value of its operand. It produces `1` when the operand is zero and `0` when the operand is non-zero. ``` #include int main() { int a = 0; int b = 10;…"
url: "https://edcret.in/docs/c-programming/operators-and-expressions/3-12-logical-not/"
updated: "2026-09-07"
category: C Programming / Operators and Expressions
---

# 3.12 Logical NOT

The logical NOT operator `!` reverses the logical value of its operand. It produces `1` when the operand is zero and `0` when the operand is non-zero.

```
#include <stdio.h>

int main()
{
    int a = 0;
    int b = 10;

    printf("!a = %d\n", !a);
    printf("!b = %d\n", !b);

    return 0;
}
```

### Example Output

```
!a = 1
!b = 0
```

### Explanation

For `a`:

```
!a
```

Since `a` is `0`, it is logically false. The `!` operator reverses it, producing `1`.

For `b`:

```
!b
```

Since `b` is non-zero, it is logically true. The `!` operator reverses it, producing `0`.

The logical NOT operator follows this behavior:

| Operand | `!` Operand |
| --- | --- |
| `0` | `1` |
| non-zero | `0` |

The result of the logical NOT operator is always `0` or `1`.
