ProgrammingHardWipro · Cognizant pattern

What is printed?

What is printed?
typedef int (*Op)(int,int);
int a(int x,int y){ return x+y; }
int b(int x,int y){ return x-y; }
Op table[2] = {a, b};
int main(void) {
    int r = table[1](table[0](3,4), 2);
    printf("%d", r);
}
  1. A. -1
  2. B. 9
  3. C. 1
  4. D. 5

Correct answer: D. 5

table[0](3,4) calls a(3,4)=7. table[1](7,2) calls b(7,2)=5.

More C Programming questions

Exams that ask this topic