What will be the output of the following C program?

#include <stdio.h>

int main()
{
int x = 10;

```
printf("%d ", sizeof(x++));

printf("%d", x);

return 0;
```

}
                        

Options

  • A. 4 10
  • B. 4 11
  • C. 11 11
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

A. 4 10

Detailed Explanation

Correct Answer: 4 10

This question tests an important property of sizeof.

The expression inside sizeof is x++. Although x++ would normally increase x by 1, the expression is not evaluated in this use of sizeof.

Therefore, x remains 10.

Since x is an integer and the question assumes an integer size of 4 bytes, sizeof(x++) returns 4.

Thus the output is 4 10.