ProgrammingHardGATE CS · Product company OA

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 compare_desc(int a, int b) { return b - a; } int main(void) { int (*cmp)(int, int) = compare_desc; printf("%d", cmp(3, 7) > 0); return 0; }

  1. A. Compilation error
  2. B. 0
  3. C. 1
  4. D. -1

Correct answer: C. 1

compare_desc(3,7) returns 7-3=4, which is greater than 0, so the comparison is true (1).

More C Programming questions

Exams that ask this topic