Question.4
A developer writes a generic 8-bit left rotation function:
uint8_t rotate_left(uint8_t val, uint8_t n) { return (val << n) | (val >> (8 - n)); }
A caller passes n = 9. What happens?
n = 9
Select Answer
It rotates by 1 — equivalent to 9 % 8
It returns 0
Undefined behavior — the expression (8 - 9) produces a negative shift count
It rotates by 9, discarding the extra bit