ProgrammingEasyAccenture · Cognizant pattern

What is printed?

What is printed?
printf("%d %d %d", 12 & 10, 12 | 10, 12 ^ 10);
  1. A. 6 14 8
  2. B. 8 14 2
  3. C. 14 8 6
  4. D. 8 14 6

Correct answer: D. 8 14 6

12 = 1100 and 10 = 1010 in binary. AND keeps common bits: 1000 = 8. OR keeps either: 1110 = 14. XOR keeps differing bits: 0110 = 6.

More C Programming questions

Exams that ask this topic