ProgrammingHardTCS NQT · Infosys
What does printf("%d", 7 % -3) print?
- A. 1
- B. -2
- C. 4
- D. 9
Correct answer: A. 1
The result of % takes the sign of the dividend in C99 and later, and 7 = (-2)(-3) + 1, so the remainder is 1.
More C Programming questions
- int a = 7; printf("%d", a++ > 7); What is printed?
- For an int, what is the value of ~5 + 1?
- int x = 12; x = x ^ (x >> 2); What is x?
- Six people stand in a circle numbered 1 to 6; starting from 1, every second person is removed until one remains. Which number survives?…
- Seven people stand in a circle numbered 1 to 7. Starting from person 1, every third person is removed until one remains. Which number…
- unsigned char a = 200, b = 100; unsigned char c = a + b; printf("%d", c); What is printed?