ProgrammingVery hard
printf("%d %d", -17 % 5, 17 % -5); What is printed in C99?
- A. 3 -3
- B. -2 -3
- C. -2 2
- D. 3 2
Correct answer: C. -2 2
C99 truncates toward zero, so -17 / 5 = -3 and -17 % 5 = -17 + 15 = -2. The sign of 17 % -5 follows 17, giving 2.
More C Programming questions
- printf("%d", (-17 % 5 + 5) % 5); What is printed in C99?
- What is printed? c #include <stdio.h> int main(void) { int a[] = {1, 2, 3, 4, 5, 6}; int l = a, r = a + 5; while (l < r) { int t = l; l++…
- What is printed? c #include <stdio.h> int main(void) { int a[] = {4, 1, 7, 3, 9}, p[6] = {0}; for (int i = 0; i < 5; i++) p[i + 1] = p[i]…
- A qsort comparator must order the uint16t values by high byte descending and, for equal high bytes, by low byte ascending. What is…
- What is printed? c #include <stdio.h> unsigned sumd(unsigned n) { return n == 0 ? 0 : n % 10 + sumd(n / 10); } int main(void) {…
- How many subsets of {1, 2, 3, 4, 5, 6} (the empty set included) have a sum divisible by 3? Compute with this program. c #include <stdio.h>…