ProgrammingHard

Records are sorted by name length first, then alphabetically, using qsort with a comparator on strlen and strcmp. Input names: bob, al, carol, dan. What is the output order?

  1. A. al bob dan carol
  2. B. al dan bob carol
  3. C. bob al dan carol
  4. D. al bob carol dan

Correct answer: A. al bob dan carol

Shorter names come first. The two-letter name al is first, then the three-letter names bob and dan in alphabetical order, then carol.

More C Programming questions

Exams that ask this topic