ProgrammingVery hard
int inc(int n) { return n + 1; } int dbl(int n) { return n * 2; } int (*f[2])(int) = {inc, dbl}; printf("%d", f[1](f[0](3))); What is printed?
- A. 8
- B. 7
- C. 4
- D. 12
Correct answer: A. 8
Calls evaluate inside out: f[0](3) = inc(3) = 4, then f[1](4) = dbl(4) = 8. 7 applies them in the other order (inc(dbl(3))), 4 stops after the inner call, and 12 treats both entries as dbl.
More C Programming questions
- int x = 2; switch (x) { case 2: x += 1; case 3: x += 10; break; default: x = 0; } printf("%d", x); What is printed?
- int p = (int[]){4, 5, 6}; printf("%d", p[2]); What is printed?
- int s = 0; for (int i = 0, j = 5; i < j; i++, j--) s += i j; printf("%d", s); What is printed?
- char s[][4] = {"ab", "xyz"}; printf("%zu", sizeof s); What is printed?
- enum { A = 3, B, C = 10, D }; printf("%d", B + D); What is printed?
- printf("%d", 1 ? 'a' : 0); What is printed?