Complete the code to set the bit at position pos in number n.
result := n | (1 << [1])
To set a bit, shift 1 left by pos and OR it with n.
Complete the code to clear the bit at position pos in number n.
result := n & ^(1 << [1])
To clear a bit, shift 1 left by pos, invert it, then AND with n.
Fix the error in the code to toggle the bit at position pos in number n.
result := n ^ (1 << [1])
To toggle a bit, XOR n with 1 shifted left by pos.
Fill both blanks to set and then clear the bit at position pos in number n.
set := n | (1 << [1]) clear := set & ^(1 << [2])
First set the bit by shifting 1 left by pos and OR with n. Then clear the same bit by AND with inverted mask.
Fill all three blanks to set, clear, and toggle the bit at position pos in number n.
set := n | (1 << [1]) clear := n & ^(1 << [2]) toggle := n ^ (1 << [3])
All three operations use the bit position pos shifted left by 1.
