MCQ
Single Best Answer
Not Set
QWhat is the output of this C code?
void main()
{
int x = 97;
int y = sizeof(x++);
printf("X is %d", x);
}
ID: #1261
Operators and Enums in C Language
12,543 views
Question Info
#1261Q ID
Not SetDifficulty
Operators and Enums in C LanguageTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer: Option A
Explanation
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.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic