ProgrammingModerateTCS NQT · Infosys
What does printf("%d %d", 17 / 5, 17 % 5) print?
- A. 3 2
- B. 3 3
- C. 2 2
- D. 4 1
Correct answer: A. 3 2
17 / 5 truncates to 3, and 17 % 5 is 2. Both operators work on int with non-negative operands, so the results are unambiguous.
More C Programming questions
- int x = 0; if (x = 5) printf("y"); else printf("n"); What is printed?
- Which expression clears the lowest three bits of an unsigned char x?
- uint32t x = 0u; x -= 1; x = x / 2 + 1; What is x?
- int a[5]; int p = &a[4]; printf("%td", p - &a[0]); What is printed?
- What does printf("%d", '7' - '0' == 7) print?
- Reversing the list 1 -> 2 -> 3 -> 4 -> 5 in place with the usual three-pointer loop, what are head->v and head->next->v afterwards?