🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Function Pointers in C: all 15 questions

Quiz: Function Pointers in C · Question 2 of 15

What does this print? (code)

What does this print?

#include <stdio.h>
int twice(int x) { return 2 * x; }
int square(int x) { return x * x; }
int main(void) {
    int (*f)(int) = twice;
    int a = f(5);
    f = square;
    printf("%d %d", a, f(a));
    return 0;
}
  1. A.10 25
  2. B.10 100
  3. C.25 100
  4. D.10 20
Answer & explanation

Correct answer: 10 100

First twice(5) = 10. Then f points to square, and square(10) = 100.

Can you get the rest right without peeking?

Take the timed Quiz: Function Pointers in C quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →