Logical NOT Operator in C

Level 254 keystrokes

Uses logical NOT (!) to invert the flag active (0, false); !active is true, so it prints "Inactive".

C code

// The flag active is 0, which C treats as false
1int active = 0;
// ! turns false into true: !0 is 1, so the block runs
2if (!active) {
// Prints "Inactive"
3 printf("Inactive\n");
4}

Output

Inactive
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this C code and how often they appear.

  • ;× 2
  • "× 2
  • (× 2
  • )× 2
  • !× 1
  • {× 1
  • }× 1
  • \× 1
  • =× 1

More C examples at level 2

← C typing practice