Bitwise XOR in C++

Level 124 keystrokes

Prints the bitwise XOR of 5 and 3, which is 6.

C++ code

// ^ compares the bits one by one: a result bit is 1 only if the two bits differ
// 5 is 101 and 3 is 011 in binary; 101 ^ 011 = 110, which is 6
1cout << (5 ^ 3) << endl;

Output

6
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