Evaluate the expression when x is 4:

ICSE Class 10 Computer Applications PYQ · 2024 Paper · Section A

2(ii)1 Mark · 2024 · Section A · 2024 Paper

Evaluate the expression when x is 4:

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

Show SolutionHide Solution↓

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

← Previous questionNext question →

Browse the free Computer Applications sample bank