Compound Assignment in C

Level 259 keystrokes

Adds 50 to total (100) with the compound assignment operator += and prints "Total: 150".

C code

// total starts at 100
1int total = 100;
// += adds the right side to the variable: total = total + 50, now 150
2total += 50;
// Prints "Total: 150"
3printf("Total: %d\n", total);

Output

Total: 150
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