ProgrammingHardCognizant GenC · C · Advanced

What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits, double 8 bytes, structs aligned to their widest member with no packing pragma)? #include <stdio.h> int main(void) { int x = 4; int y = (x > 2) && (x < 10); int z = (x > 10) || (x == 4); printf("%d %d", y, z); return 0; }

  1. A. 1 1
  2. B. 1 0
  3. C. 0 1
  4. D. 0 0

Correct answer: A. 1 1

x=4 satisfies both 2<x<10 so y=1; the || short-circuits on the second operand since x==4 is true, giving z=1.

More C Programming questions

Exams that ask this topic