ProgrammingVery hardTCS NQT · Infosys

What does printf("%d", strcmp("apple", "Apple") > 0) print?

  1. A. true (1)
  2. B. false (0)
  3. C. 0
  4. D. -1

Correct answer: A. true (1)

The C standard compares strings as unsigned char, and 'a' (97) is greater than 'A' (65). So strcmp returns a positive value and the comparison is true.

More C Programming questions

Exams that ask this topic