Complete the code to perform bitwise AND on two integers a and b.
int result = a [1] b;The bitwise AND operator & compares each bit of two numbers and returns 1 only if both bits are 1.
Complete the code to perform a left shift by 2 bits on integer x.
int shifted = x [1] 2;
The left shift operator << moves bits to the left, effectively multiplying the number by 2 for each shift.
Fix the error in the code to perform bitwise NOT on variable val.
int result = [1]val;The bitwise NOT operator ~ flips all bits of the number.
Fill both blanks to create a mask that sets the 3rd bit of number num using bitwise OR.
int mask = 1 [1] 2; int result = num [2] mask;
Shift 1 left by 2 to create a mask for the 3rd bit, then use OR | to set that bit in num.
Fill all three blanks to create a mask for the 1st bit, toggle the 1st bit of variable val using XOR, and isolate the 1st bit using AND.
int mask = 1 [1] 0; int toggled = val [2] mask; int isolated = val [3] mask;
Shift 1 left by 0 to create mask for 1st bit, XOR ^ toggles the bit, AND & isolates the bit.
