ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
printf("%d", (-17 / 5) * 5 + (-17 % 5) == -17);
}- A. 0
- B. 2
- C. 1
- D. 3
Correct answer: C. 1
C99 division truncates toward zero, so -17 / 5 = -3 and -17 % 5 = -2. Then (-3) * 5 + (-2) = -17, so the identity holds.
More C Programming questions
- How many leading zero bits does the 16-bit value 0x0123 have? Count them with this program. c #include <stdint.h> #include <stdio.h> int…
- What is printed? c #include <stdio.h> #include <stdlib.h> int cmp(const void a, const void b) { return atoi((const char const )a)…
- What is printed? c #include <stdio.h> #include <stdlib.h> int cmp(const void a, const void b) { const int x = a, y = b; if (x[0] != y[0])…
- What is the digit sum of 2^15 = 32768? The recursion below computes it. Assume int is 32 bits. What is printed? c #include <stdio.h> int…
- How many subsets of {1, 2, 3} (the empty set included) have a sum divisible by 3? The recursion below counts them. What is printed? c…
- How many bit positions are zero in both 0xAAAA and 0x5555 within 16 bits? Count them with this program. c #include <stdint.h> #include…