Float Division in C++

Level 126 keystrokes

Prints the floating-point division 7.0 / 2, which is 3.5.

C++ code

// 7.0 is a double, so the int 2 is converted to double before dividing
// The division keeps the fractional part, so the result is 3.5
1cout << (7.0 / 2) << endl;

Output

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

More C++ examples at level 1

← C++ typing practice