- A X is 97
- B X is 98
- C X is 99
- D Run time error
- Share this MCQ
Answer:
A
Share this MCQ
Option A
The output of the given C code would be:
X is 97
In the code, x
is assigned the value 97. The line int y = sizeof(x++);
attempts to get the size (in bytes) of the expression x++
, which is a post-increment operation on x
. The sizeof
operator is evaluated at compile time and doesn't actually increment x
.
So, even though the sizeof(x++)
line appears to increment x
, the value of x
remains 97, and the output prints "X is 97". The increment operation within sizeof
doesn't affect the value of x
in this case.
Share this MCQ