Which of the following statement is correct about the code snippet given below?
#include <stdio.h>
int main()
{
int n = 12, k;
printf("%d", (k = sizeof( n + 12.0))++);
return 0;
}
Answer: C
Correct answer: The code will result in a compile time error
(k = sizeof(n + 12.0))++ tries to increment the result of an assignment expression. That result is a value, not an object, so it is not a modifiable lvalue and the compiler rejects it. (Had the increment been dropped, sizeof(n + 12.0) would be 8 on a typical machine, since the int is promoted to double.)
Please log in or register to report this question.