ProgrammingVery hardGATE CS · Campus placements

Which statement about sizeof is correct when x is an int variable initialised to 5?

  1. A. sizeof(x++) increments x to 6
  2. B. sizeof evaluates its operand at run time every time
  3. C. sizeof(x++) leaves x unchanged, because the operand is not evaluated, except for variable-length array types
  4. D. sizeof is a library function called at run time

Correct answer: C. sizeof(x++) leaves x unchanged, because the operand is not evaluated, except for variable-length array types

sizeof is resolved from the operand's type, so the operand is not evaluated except when it has a variable-length array type. Hence x++ inside sizeof has no effect on x.

More C Programming questions

Exams that ask this topic