ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    printf("%d", (7 & 5) | (2 ^ 6) << 1);
}
  1. A. 12
  2. B. 9
  3. C. 15
  4. D. 13

Correct answer: D. 13

7 & 5 = 5, 2 ^ 6 = 4, and 4 << 1 = 8 is computed before the OR, because shifts bind tighter than |. So the result is 5 | 8 = 13.

More C Programming questions

Exams that ask this topic