ProgrammingModerateTCS NQT · Infosys

int x = 0x1F; What does printf("%d", 07 + 0x1F) print?

  1. A. 26
  2. B. 0x26
  3. C. 38
  4. D. 24

Correct answer: C. 38

07 is octal for 7 and 0x1F is 31 in hexadecimal, so the sum is 38. A leading zero makes a constant octal, which catches many readers.

More C Programming questions

Exams that ask this topic