ProgrammingHardAccenture · Capgemini · C

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 maxOf(int a, int b) { return a > b ? a : b; } int maxOf3(int a, int b, int c) { return maxOf(maxOf(a, b), c); } int main(void) { printf("%d", maxOf3(7, 12, 9)); return 0; }

  1. A. 12
  2. B. 7
  3. C. 28
  4. D. 9

Correct answer: A. 12

maxOf3 composes maxOf: maxOf(7,12)=12, then maxOf(12,9)=12.

More C Programming questions

Exams that ask this topic