What is the output of the code snippet given below?

ICSE Class 10 Computer Applications PYQ · 2025 Improvement · Section A

1(vii)1 Mark · 2025 · Section A · 2025 Improvement

What is the output of the code snippet given below?

int lives = 5;
System.out.print(lives--);
System.out.print(lives);
Show SolutionHide Solution↓

5 4

Reason — In System.out.print(lives--), the post-decrement operator (lives--) prints the current value of lives (which is 5) first, then decreases it to 4. The next System.out.print(lives) prints the updated value 4.

← Previous questionNext question →

Browse the free Computer Applications sample bank