Modulo in C++

Level 123 keystrokes

Prints the remainder of 17 divided by 5, which is 2.

C++ code

// The % operator gives the remainder of an integer division
// 17 = 5 * 3 + 2, so 17 % 5 is 2
1cout << 17 % 5 << endl;

Output

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.

  • <× 4
  • ;× 1
  • %× 1

More C++ examples at level 1

← C++ typing practice