ICSE Class 10 Computer Applications Question 17 of 30

Solved 2024 Question Paper ICSE Class 10 Computer Applications — Question 22

Back to all questions
22
Question

Question 2(ii)

Evaluate the expression when x is 4:

x += x++ * ++x % 2;

Answer

The given expression is evaluated as follows:

x += x++ * ++x % 2
x = x + (x++ * ++x % 2) (x = 4)
x = 4 + (4 * ++x % 2) (x = 5)
x = 4 + (4 * 6 % 2) (x = 6)
x = 4 + (24 % 2) (x = 6)
x = 4 + 0 (x = 6)
x = 4