ProgrammingModerateTCS NQT · Infosys pattern

What is printed?

What is printed?
printf("%d", 010 + 0x10 + 10);
  1. A. 36
  2. B. 30
  3. C. 34
  4. D. 26

Correct answer: C. 34

A leading 0 makes an octal literal: 010 = 8. 0x10 is hexadecimal 16. So 8 + 16 + 10 = 34. Reading 010 as ten gives 36.

More C Programming questions

Exams that ask this topic