ProgrammingEasyTCS NQT · Infosys pattern

What is printed?

What is printed?
printf("%d %d %d", 5 > 3 && 2 > 4, !0, !!7);
  1. A. 0 1 1
  2. B. 1 1 7
  3. C. 0 1 7
  4. D. 0 0 1

Correct answer: A. 0 1 1

Relational and logical operators in C produce int 0 or 1. 2 > 4 is false, so the && is 0. !0 is 1. !!7 first gives !7 = 0 and then !0 = 1 — the double negation normalises any non-zero value to 1, it does not return 7.

More C Programming questions

Exams that ask this topic