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
43 views
Question Info
#24269Q ID
EasyDifficulty
ICSE Computer Application - Class X - 2025 SPECIMEN QUESTION PAPERTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer: Option D
Explanation
Let's carefully analyze the problem:
The student wrote:
x = +2;
-
This does not increase
xby 2; it just assigns the value+2tox.
To increase x by 2, the correct statements are:
-
x += 2;→ This is shorthand forx = x + 2;. ✅ -
x = x + 2;→ Explicitly increasesxby 2. ✅ -
x = 2;→ This assigns 2 tox, it does not increase it. ❌
So the correct options are A and C.
Answer: (d) Both A and C
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic