ProgrammingHard

The Gray code of 5 (binary 101), computed as n ^ (n >> 1), is which value?

  1. A. 6
  2. B. 3
  3. C. 5
  4. D. 7

Correct answer: D. 7

5 >> 1 is 2 and 5 ^ 2 = 7. Successive Gray codes differ in exactly one bit.

More C Programming questions

Exams that ask this topic