Integer Division in C++

Level 124 keystrokes

Prints the integer division 7 / 2, which is 3.

C++ code

// Both operands are int, so the result is an int as well
// The exact quotient 3.5 is truncated toward zero, giving 3 (the remainder 1 is dropped)
1cout << (7 / 2) << endl;

Output

3
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
  • )× 1
  • /× 1

More C++ examples at level 1

← C++ typing practice