← 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?
- A.Call qsort with a negative size
- B.Sort ascending and hope the caller reverses it
- C.Compare the second element with the first instead of the first with the second
- 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 →