ICSE Class 10 Computer Applications
Question 29 of 30
Solved Sample Paper 2 — Question 29
Back to all questions 29
Question Question 2(ix)
Give the output of the following expression, when a = 6.
a += ++a + a++ + a-- + a-- + --a + ++a
The output will be 46.
Explanation
a += ++a + a++ + a-- + a-- + --a + ++a [a = 6]
a = a + (++a + a++ + a-- + a-- + --a + ++a) [a = 6]
a = 6 + (7 + a++ + a-- + a-- + --a + ++a) [a = 7]
a = 6 + (7 + 7 + a-- + a-- + --a + ++a) [a = 8]
a = 6 + (7 + 7 + 8 + a-- + --a + ++a) [a = 7]
a = 6 + (7 + 7 + 8 + 7 + --a + ++a) [a = 6]
a = 6 + (7 + 7 + 8 + 7 + 5 + ++a) [a = 5]
a = 6 + (7 + 7 + 8 + 7 + 5 + 6) [a = 6]
a = 6 + 40
a = 46