Decrement Operator in C

Level 254 keystrokes

Lowers count from 5 to 4 with the decrement operator -- and prints "count = 4".

C code

// count starts at 5
1int count = 5;
// -- subtracts 1 from count (same as count = count - 1), so count becomes 4
2count--;
// Prints the new value: "count = 4"
3printf("count = %d\n", count);

Output

count = 4
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.

  • ;× 3
  • -× 2
  • "× 2
  • =× 2
  • ,× 1
  • (× 1
  • )× 1
  • \× 1
  • %× 1

More C examples at level 2

← C typing practice