Subtraction Assignment in C

Level 258 keystrokes

Subtracts 25 from money (100) with the compound assignment operator -= and prints "Left: 75".

C code

// money starts at 100
1int money = 100;
// -= subtracts the right side from the variable: money = money - 25, now 75
2money -= 25;
// Prints the remaining amount: "Left: 75"
3printf("Left: %d\n", money);

Output

Left: 75
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
  • -× 1
  • ,× 1
  • :× 1
  • (× 1
  • )× 1
  • \× 1
  • %× 1

More C examples at level 2

← C typing practice