Left Shift in C++

Level 125 keystrokes

Shifts 1 left by 3 bits and prints the result, 8.

C++ code

// The parentheses make << a bit shift here instead of stream output
// Shifting left by 3 multiplies by 2 three times: binary 1 becomes 1000, which is 8
1cout << (1 << 3) << 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.

  • <× 6
  • ;× 1
  • (× 1
  • )× 1

More C++ examples at level 1

← C++ typing practice