ProgrammingModerateTCS NQT · Infosys pattern
What is printed?
What is printed?
printf("%d", 010 + 0x10 + 10);- A. 36
- B. 30
- C. 34
- 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
- What happens? c for (unsigned int i = 3; i >= 0; i--) printf("%u ", i);
- What is printed? c char s[] = "abc0def"; printf("%zu %zu", sizeof(s), strlen(s));
- What is printed? c printf("%zu", strlen("atbn"));
- What is printed? c int a = -1, b = 1; if (a > 0) if (b > 0) printf("X"); else printf("Y"); printf("Z");
- What is printed? c int x = 4; if (x & 1 == 0) printf("even"); else printf("odd");
- What is printed? c int f(int n) { static int s = 0; s += n; if (n > 0) f(n - 1); return s; } ... printf("%d ", f(3)); printf("%d", f(3));