ICSE Class 10 Computer Applications
Question 28 of 30
Solved Sample Paper 3 — Question 28
Back to all questions 28
Question Question 2(viii)
Evaluate the following expressions, when int a = 8, b = 14.
(a) b/a++
(b) --a + b-- + a
(a) b/a++
b / a++
⇒ 14 / 8 [Postfix operator first uses the value then increments it]
⇒ 1 [Integer division is performed as both a and b are int variables]
Hence, the expression evaluates to 1
(b) --a + b-- + a
--a + b-- + a
⇒ 7 + b-- + a [a = 7, Prefix operator first decrements the value then uses it]
⇒ 7 + 14 + 7 [b = 13, Postfix operator first uses the value then decrements it]
⇒ 28
Hence, the expression evaluates to 28