Bitwise OR in C++

Level 124 keystrokes

Prints the bitwise OR of 5 and 3, which is 7.

C++ code

// | compares the bits one by one: a result bit is 1 if either bit is 1
// 5 is 101 and 3 is 011 in binary; 101 | 011 = 111, which is 7
1cout << (5 | 3) << endl;

Output

7
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