Skills101
← All practice quizzes

Quiz: Function Pointers in C

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

A function has an address too, and a pointer can hold it. Learn the syntax of function pointers, pass functions as callbacks, sort anything with qsort, and build a menu with an array of function pointers.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What does int (*fp)(double); declare?

  2. Question 2

    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;
    }
    
  3. Question 3

    What does int *f(int); declare?

  4. Question 4

    A qsort comparator should return a negative value when:

  5. Question 5

    Why do qsort comparators take const void * parameters?

🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →