← All topics
Quiz: Function Pointers in C: questions with answers
15 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. What does int (fp)(double); declare?
- Q2. What does this print? (code)
- Q3. What does int f(int); declare?
- Q4. A qsort comparator should return a negative value when:
- Q5. Why do qsort comparators take const void parameters?
- Q6. What is a callback?
- Q7. What does this print? (code)
- Q8. Why is return a - b; risky as a comparator for ints?
- Q9. Which line correctly stores the address of void greet(void) in a pointer?
- Q10. Why does a typedef help with function pointers?
- Q11. What does this print? (code)
- Q12. What does this print? (code)
- Q13. If fp is a function pointer, are fp(5) and (fp)(5) different?
- Q14. How do you make a qsort comparator sort ints in descending order?
- Q15. What happens if you call a function pointer that is NULL?