Discussion
Which statement is suitable to check 3rd (count from 0) bit is high (set) or not?
Answer: D
Correct answer: Both (1) and (2)
The two expressions build the same mask by different routes. 1<<3 shifts a single 1 into position 3, giving \( 1000_2 \); 0x08 is that same value written directly. ANDing with either isolates bit 3.
The third option is the trap: 0x03 is \( 0011_2 \), which selects bits 0 and 1 - a mask for two low bits, not for bit 3. The shift form is generally preferred in code because the bit number appears literally, so 1<<k reads as "bit k" without the reader converting hexadecimal in their head.
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