ProgrammingHardIBM · Deloitte · Product Company SDE

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 addf(int a, int b) { return a + b; } typedef int (*BinOp)(int, int); int main(void) { BinOp f = addf; printf("%d", f(10, 20)); return 0; }

  1. A. 10
  2. B. 30
  3. C. Compilation error
  4. D. 20

Correct answer: B. 30

A typedef'd function-pointer type behaves exactly like the equivalent raw declaration; f(10,20) calls addf(10,20)=30.

More C Programming questions

Exams that ask this topic