ProgrammingVery hardTCS NQT · Infosys

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    printf("%d", (1 << 4) | 3 & 5);
}
  1. A. 17
  2. B. 1
  3. C. 21
  4. D. 5

Correct answer: A. 17

& binds tighter than |, so 3 & 5 = 1, and shift binds tighter than |, so 16 | 1 = 17.

More C Programming questions

Exams that ask this topic