Skip to content
C

Pre- vs Post-Increment

Mediumjava

Read an integer x. Simulate both forms of increment starting from x and print what each produces.

  • Post-increment: r1 = a++r1 gets the old value, then a becomes x + 1.
  • Pre-increment: r2 = ++bb becomes x + 1 first, then r2 gets the new value.

Input: one integer x.

Output: two lines:

<r1> <a>
<r2> <b>

Input (stdin)

Output

Run your code to see output here...