Octal Number in C++

Level 120 keystrokes

Prints the octal literal 010 in decimal, which is 8.

C++ code

// A leading 0 makes an integer literal octal, so 010 is not ten
// Octal 10 = 1 * 8 + 0 = 8; beware of leading zeros when you mean decimal
1cout << 010 << endl;

Output

8
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