Complete the code to perform a bitwise AND operation between 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 the variable 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 correctly perform bitwise NOT on the variable num.
int inverted = [1]num;The bitwise NOT operator ~ flips every bit of the number.
Fill both blanks to create a mask that sets the 3rd bit of number n to 1 using OR operation.
int mask = 1 [1] 2; int result = n [2] mask;
Shift 1 left by 2 to create a mask for the 3rd bit, then use OR | to set that bit in n.
Fill all three blanks to toggle the 4th bit of variable val using XOR operation.
int toggleMask = 1 [1] 3; int toggledVal = val [2] toggleMask; bool isToggled = (toggledVal [3] toggleMask) != 0;
Shift 1 left by 3 to create mask for 4th bit, XOR ^ toggles that bit, AND & checks if bit is set.
