Bitwise operators
`&` AND, `|` OR, `^` XOR, `~` NOT, `<<` left shift, `>>` right shift. Use parentheses; precedence surprises are common.
int a = x & y; // AND
int b = x | y; // OR
int c = x ^ y; // XOR
int d = ~x; // NOT
DSA · 9 sections
Bitwise tricks, masks, subset patterns, and the bit-hack gotchas that show up in interviews.
`&` AND, `|` OR, `^` XOR, `~` NOT, `<<` left shift, `>>` right shift. Use parentheses; precedence surprises are common.
int a = x & y; // AND
int b = x | y; // OR
int c = x ^ y; // XOR
int d = ~x; // NOT
AND is 1 only if both 1. OR is 0 only if both 0. XOR is 1 if bits differ.
`x << n` shifts bits left, filling zeros on the right; equals multiply by 2^n when no overflow. Unsigned wraps mod 2^n; since C++20 signed overflow is defined mod 2^N (see Left shift overflow).
98 more cards in this sheet
Unlock the DSA & Data Structures bundle — ₹399
One-time payment. Unlocks this sheet and 8 other sheets in the bundle, plus a typeset PDF of each.
Unlock the bundle See all bundles
Or get all 76 sheets for ₹999 — one payment, every future sheet included.
What's new and the interview questions people are actually getting asked. No spam.