What operation does the following ‘C’ statement perform?
star = star ^ 0b00100100;
(A) Toggles bits 2 and 5 of
The exclusive OR has this truth table:
exclusive OR
A B A^B ----------- 1 1 0 1 0 1 0 1 1 0 0 0
We can see that if B is true (1) then A is flipped (toggled), and if it's false (0) A is left alone. So the answer is (A).
B
true
1
A
false
0