What is the output of this C code?
void main()
{
int x = 97;
int y = sizeof(x++);
printf("X is %d", x);
}
Answer: A
Correct answer: x is 97
sizeof is evaluated at compile time from the type of its operand, and its operand is not executed. So x++ never runs, y becomes sizeof(int), and x is still 97. (Variable-length arrays are the one exception where the operand is evaluated.)
Please log in or register to report this question.