+1 vote
in Data Structures & Algorithms I by (110k points)
Which of the following bitwise operations will you use to toggle a particular bit?

(a) OR

(b) AND

(c) XOR

(d) NOT

The question is from Bit Array in section Arrays Types of Data Structures & Algorithms I

I had been asked this question in an online interview.

1 Answer

+1 vote
by (408k points)
selected by
Best answer
Correct option is (c) XOR

To explain: 1 XOR 1 = 0, 0 XOR 1 = 1, note that NOT inverts all the bits, while XOR toggles only a specified bit.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.