ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    printf("%d", 07 + 0x10);
}
  1. A. 23
  2. B. 17
  3. C. 24
  4. D. 71

Correct answer: A. 23

07 is an octal literal equal to 7, and 0x10 is hexadecimal 16, so the total is 23. Reading 07 as decimal would give the same value here, so the trap is 0x10 read as 10.

More C Programming questions

Exams that ask this topic