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. 6The pre-increment operator ++x increments x before its value is used. Starting from x = 5, the printed value is 6.

  1. A.

    4

  2. B.

    5

  3. C.

    6

  4. 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.

Explore the full course: Isro

Loading lesson…