ProgrammingModerateProduct-company MCQ pattern
What is printed by a C99 (or later) compiler?
What is printed by a C99 (or later) compiler?
printf("%d %d", -7 / 2, -7 % 2);- A. -4 -1
- B. -4 1
- C. -3 -1
- D. -3 1
Correct answer: C. -3 -1
Since C99 integer division truncates toward zero, so -7 / 2 = -3. The remainder satisfies (a / b) × b + a % b = a, so -7 % 2 = -7 - (-6) = -1; its sign follows the dividend. -4 and 1 are Python's floor-division results.
More C Programming questions
- What is printed? c char s = "Campus"; printf("%c%s", (s + 1), s + 4);
- What is printed? c printf("%d", printf("hello"));
- On a 64-bit system (8-byte pointers, 4-byte int), what does f print? c void f(int a[10]) { printf("%zu", sizeof(a)); }
- How many times is fib called in total (including the first call) when evaluating fib(5)? c int fib(int n) { if (n <= 1) return n; return…
- What is printed? c int x = 181, c = 0; while (x) { x &= x - 1; c++; } printf("%d", c);
- What is printed? c printf("%d", 1 << 3 + 1);