Complete the code to perform a bitwise AND operation between a and b.
int result = a [1] b;The bitwise AND operator is &. It compares each bit of two numbers and returns 1 only if both bits are 1.
Complete the code to perform a bitwise OR operation between x and y.
int combined = x [1] y;The bitwise OR operator is |. It compares each bit of two numbers and returns 1 if at least one bit is 1.
Fix the error in the code to perform a bitwise XOR operation between m and n.
int diff = m [1] n;The bitwise XOR operator is ^. It returns 1 only when the bits are different.
Fill both blanks to create a mask that keeps only the lower 4 bits of value.
int mask = (1 [1] 4) [2] 1;
Shift 1 left by 4 bits to get 16, then subtract 1 to get 15 (binary 1111), which masks the lower 4 bits.
Fill all three blanks to toggle the 3rd bit of num using XOR.
int toggle = num [1] (1 [2] 2 [3] 0);
Use XOR (^) to toggle bits. Shift 1 left by 2 to get the 3rd bit mask, then OR (|) to form the mask.