Single Choice Moderate

Qx += 5 is same as:

ID: #25831 MCQ Quiz - Class 8 - Programming 5 views
Question Info
#25831Q ID
ModerateDifficulty
MCQ Quiz - Class 8 - ProgrammingTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A x = x + 5
  • B x = 5
  • C x = x - 5
  • D x = 5 - x
Correct Answer

Explanation

Correct Answer Explanation:

x += 5 is a compound assignment operator, equivalent to x = x + 5. It adds 5 to the current value of x.

Why the other options are incorrect:

  • Option B: x = 5 would replace x's value with 5, ignoring the previous value.
  • Option C: x = x - 5 uses subtraction, not addition.
  • Option D: x = 5 - x is a different operation.

Share This Question

Challenge a friend or share with your study group.