Which of the following is not correct in C++?

2018

Which of the following is not correct in C++?

  1. A.

    x -= 2; is the same as x = x - 2;

  2. B.

    x *= 2; is the same as x = x * 2;

  3. C.

    x %= 2; is the same as x = x/2

  4. D.

    x /= 2; is the same as x = x/2

Attempted by 238 students.

Show answer & explanation

Correct answer: C

Step 1:
x /= 2 -> x = x/2
x /= 2 is a compound assignment operator. It is equivalent to x = x / 2

Step 2:
Similarly, other compound operators are:
x -= 2 → x = x - 2
x = 2 → x = x 2

Step 3:
Thus, options 1, 2, and 4 are correct because they correctly represent compound assignment operations.

Step 4:
x %= 2 is different. It represents:
x = x % 2 (remainder), not division.

Conclusion:
The statement “x %= 2 is the same as x = x / 2” is incorrect, while the others are correct.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs