What will be the output of the following C program?
#include <stdio.h>
int main()
{
int i = 5;
```
printf("%d ", sizeof(i++));
printf("%d", i);
return 0;
```
}
Options
-
A.
4 5
-
B.
4 6
-
C.
6 6
-
D.
More than one of the above
-
E.
None of the above
Correct Answer (Detailed Explanation is Below)
A.
4 5
Detailed Explanation
Correct Answer: 4 5
The expression inside sizeof is i++.
Normally, the post-increment operator would increase i after using its current value. However, because the expression is used as the operand of sizeof, it is not evaluated in this situation.
Therefore, i remains 5.
The type of i++ is int, so sizeof(i++) returns the size of an integer, which is 4 bytes under the given assumption.