What is the output of this C code?
int main()
{
int x = 2, y = 2;
x /= x / y;
printf("%d\n", x);
return 0;
}
Answer: A
Correct answer: 2
x /= x / y; is x = x / (x / y). The right-hand side is computed first, with integer division throughout:
So x is unchanged at 2.
Please log in or register to report this question.