Binary Number in C++

Level 123 keystrokes

Prints the binary literal 0b1010 in decimal, which is 10.

C++ code

// The 0b prefix marks a binary literal (available since C++14)
// From the right the digits are worth 1, 2, 4, 8: 1010 = 8 + 2 = 10
1cout << 0b1010 << endl;

Output

10
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

More C++ examples at level 1

← C++ typing practice