🎙 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 5 of 15

Why do qsort comparators take const void parameters?

Why do qsort comparators take const void * parameters?

  1. A.void pointers are faster
  2. B.qsort works for any element type, so it passes untyped pointers that the comparator casts to the real type
  3. C.To stop the array from being sorted
  4. D.Because C has no int pointers
Answer & explanation

Correct answer: qsort works for any element type, so it passes untyped pointers that the comparator casts to the real type

qsort knows only the element size, not the type; the comparator knows the type.

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 →