15. Bitwise Operations-II

Question.3

A developer configures a 2-bit mode field (bits 2–3) in a control register. The register currently holds 0x0F. He wants to change the mode from 11 to 01. He writes:

reg &= ~(0x03 << 2);   // Step 1: Clear bits 2-3
reg |= (0x01 << 2);     // Step 2: Set new value

What is the final value of reg?

Need Help? Refer to the Quick Guide below

Select Answer

Restart quiz!