ProgrammingModerateGATE CS · Campus placements

What does printf("%d", '7' - '0' == 7) print?

  1. A. 7
  2. B. 1
  3. C. 0
  4. D. compile error

Correct answer: B. 1

The digit characters are contiguous in every conforming character set, so '7' - '0' is 7 and the comparison is true, printing 1.

More C Programming questions

Exams that ask this topic