Multiple choice

If x=5 and y=++x, what are the values of x and y?

  1. x=5, y=5

  2. x=5, y=6

  3. x=6, y=6

  4. x=6, y=5

  5. x=5, y=7

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

This is the correct answer. Here student uses Pre increment operator of C programming language and increases the value of x by 1. After that he assigns the value of x to y and he also assigns new value to x, which is 6. So, both x and y contain 6.