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

How do you make a qsort comparator sort ints in descending order?

How do you make a qsort comparator sort ints in descending order?

  1. A.Call qsort with a negative size
  2. B.Sort ascending and hope the caller reverses it
  3. C.Compare the second element with the first instead of the first with the second
  4. D.Return 0 from the comparator
Answer & explanation

Correct answer: Compare the second element with the first instead of the first with the second

Swapping the roles of the two arguments reverses the order qsort produces.

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 →