Discussion
What is the value of x at the end?
uint8_t x = 0x5A; x &= 0x0F; x |= 0x80;
Answer: B
Correct answer: 0x8A
\( 0x5A \) is 0101 1010. Masking with \( 0x0F \) keeps the low nibble, giving 0000 1010, or \( 0x0A \). Setting the top bit with \( 0x80 \) gives 1000 1010, or \( 0x8A \). The two operations are the standard idioms: AND with a mask to keep bits, OR with a mask to set them.
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