ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
printf("%d", 07 + 0x10);
}- A. 23
- B. 17
- C. 24
- 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
- What is printed? c #include <stdio.h> int main(void) { unsigned mask = ~0u << 4; printf("%X", mask >> 28); }
- How many pairs (i, j) with i < j have a[i] == a[j]? Compute with this program. c #include <stdio.h> int main(void) { int a[] = {1, 2, 3…
- What is printed? c #include <stdio.h> int main(void) { int x = -1; printf("%u", (unsigned)x >> 28); }
- What is printed? c #include <stdio.h> int ways(int n, int coins[], int k) { if (n == 0) return 1; if (n < 0 || k == 0) return 0; return…
- What is printed? Assume unsigned int is 32 bits. c #include <stdio.h> unsigned f(unsigned n) { unsigned r = 1; for (unsigned i = 2; i <=…
- What is printed? c #include <stdio.h> int main(void) { unsigned a[] = {5, 3}; printf("%u", a[0] - a[1] 2); }