Machine-translated by Google. Questions are authored in English.
Top

Discussion

What is the value of x after these three lines run?

uint8_t x = 0xF0;
x = x >> 2;
x |= 0x03;

  • A.0x3F
  • B.0x3C
  • C.0xC3
  • D.0xF3

Answer: A

Shifting 0xF0 right by two gives 0x3C, and setting the two low bits with an inclusive or gives 0x3F. Working in binary rather than hex makes such manipulations far less error-prone: 1111 0000 becomes 0011 1100 and then 0011 1111.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.