Bitwise AND in C++

Level 124 keystrokes

Prints the bitwise AND of 5 and 3, which is 1.

C++ code

// & compares the bits one by one: a result bit is 1 only if both bits are 1
// 5 is 101 and 3 is 011 in binary; 101 & 011 = 001, which is 1
1cout << (5 & 3) << endl;

Output

1
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