ProgrammingHardHCL · Tech Mahindra · C placement

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 a = 2, b = 3, c = 4; int r = a + b * c - a / b; printf("%d", r); return 0; }

  1. A. 13
  2. B. 20
  3. C. 15
  4. D. 14

Correct answer: D. 14

* and / bind tighter than + and -, and a/b is integer division (2/3=0): 2 + 12 - 0 = 14.

More C Programming questions

Exams that ask this topic