ProgrammingHardGATE CS · Campus placements

uint32_t x = 0xFFFFFFFFu; How many times does while (x > 0) x >>= 1; execute its body, counting from the start?

  1. A. 32
  2. B. 31
  3. C. 33
  4. D. 64

Correct answer: A. 32

Each right shift removes one bit, and a value with all 32 bits set needs 32 shifts to reach 0. The loop is a standard way to count bit length.

More C Programming questions

Exams that ask this topic