← 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?
- A.Subtraction is slow
- B.For large values the subtraction can overflow and give the wrong sign
- C.qsort does not allow subtraction
- 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 →