Modulo Assignment in C

Level 255 keystrokes

Replaces num (17) with the remainder of dividing it by 5 using the compound assignment operator %= and prints "Remainder: 2".

C code

// num starts at 17
1int num = 17;
// %= stores the remainder: num = num % 5; 17 = 5 * 3 + 2, so num becomes 2
2num %= 5;
// Prints "Remainder: 2"
3printf("Remainder: %d\n", num);

Output

Remainder: 2
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