What is the output of the following code? int x = 5; printf("%d", x++);
Correct answer
A. 5
11 views
A. 5
11 views
The postfix ++ returns the current value (5) and then increments x to 6. So the output is 5. If it were ++x, the output would be 6. This distinction is a classic exam question.
Asked in: Matric,FBISE
Not sure why the answer is A? Ask here and get an explanation.