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

Why is return a - b; risky as a comparator for ints?

Why is return a - b; risky as a comparator for ints?

  1. A.Subtraction is slow
  2. B.For large values the subtraction can overflow and give the wrong sign
  3. C.qsort does not allow subtraction
  4. D.It sorts in descending order
Answer & explanation

Correct answer: For large values the subtraction can overflow and give the wrong sign

Use (a > b) - (a < b), which always returns -1, 0 or 1.

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 →