ProgrammingHardTCS NQT · Infosys

A qsort comparator orders the elements in descending order. After sorting {5, 9, 2}, what is the first element?

  1. A. 2
  2. B. 5
  3. C. 9
  4. D. 7

Correct answer: C. 9

Descending order puts the largest value first, which is 9. Reversing the comparator's sign flips the order without changing the algorithm.

More C Programming questions

Exams that ask this topic