ProgrammingModerate

The sequence n ^ (n >> 1) for n = 0, 1, 2, 3 gives what list?

  1. A. 0, 1, 2, 3
  2. B. 0, 2, 3, 1
  3. C. 1, 2, 3, 0
  4. D. 0, 1, 3, 2

Correct answer: D. 0, 1, 3, 2

These are the first four Gray codes, and consecutive values differ in one bit.

More C Programming questions

Exams that ask this topic