ProgrammingHardTCS NQT · Infosys
A qsort comparator orders the elements in descending order. After sorting {5, 9, 2}, what is the first element?
- A. 2
- B. 5
- C. 9
- 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
- uint32t x = 491u; What is (x >> 3) & 7? (491 is 0x1EB.)
- uint32t r = 2147483648u % 1000u; What is r?
- uint32t p = 65536u 65537u; What is p?
- int a[] = {1, 2, 3, 4, 5}; int p = a; p += 3; printf("%d", p--); What is printed?
- int x = 10; int px = &x; px += px 2; What is x?
- What is ~0u / 2 + 1 for a 32-bit unsigned int?