Discussion
Bitwise | can be used to set a bit in number.
Answer: A
Correct answer: Yes
Setting a single bit is n |= (1 << k). The shift builds a mask with one 1 in position \( k \); OR forces that position to 1 and leaves every other bit unchanged, since \( b \mathbin{|} 0 = b \).
The three basic single-bit operations follow the same shape and differ only in the operator: OR with the mask to set, AND with its complement to clear, and XOR with the mask to toggle. Testing uses AND with the mask without storing the result.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development