Question 11
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
int main(void) {
int n = 10;
n /= 4;
n *= 4;
printf("%d\n", n);
return 0;
}
- A 8 Correct
- B 10
- C 12
- D 2
Correct Answer: Option A
10 / 4 is 2 in integer division, and 2 × 4 = 8. Dividing first loses information; multiply first when the result must be exact (watching for overflow).
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!