What does the following code print? int x = 5; printf("%d", ++x);
What does the following code print?
int x = 5;
printf("%d", ++x);
Answer: C. 6 — The pre-increment operator ++x increments x before its value is used. Starting from x = 5, the printed value is 6.
- A.
4
- B.
5
- C.
6
- D.
Compilation error
Attempted by 882 students.
Show answer & explanation
Correct answer: C
The pre-increment operator ++x increments x before its value is used. Starting from x = 5, the printed value is 6.
Loading lesson…