MCQ Single Best Answer Easy

Q

A student executes the following code to increase the value of a variable 'x' by 2.

He has written the following statement, which is incorrect.

x = +2;

What will be the correct statement?

A. x +=2;

B. x=2;

C. x=x+2;

ID: #24269 ICSE Computer Application - Class X - 2025 SPECIMEN QUESTION PAPER 42 views
Question Info
#24269Q ID
EasyDifficulty
ICSE Computer Application - Class X - 2025 SPECIMEN QUESTION PAPERTopic

Choose the Best Option

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

  • A Only A
  • B Only C
  • C All the three
  • D Both A and C
Correct Answer: Option D

Explanation

Let's carefully analyze the problem:

The student wrote:

x = +2;
  • This does not increase x by 2; it just assigns the value +2 to x.

To increase x by 2, the correct statements are:

  1. x += 2; → This is shorthand for x = x + 2;. ✅

  2. x = x + 2; → Explicitly increases x by 2. ✅

  3. x = 2; → This assigns 2 to x, it does not increase it. ❌

So the correct options are A and C.

Answer: (d) Both A and C

Share This Question

Challenge a friend or share with your study group.