+ 2
What will i and j equal after the code below is executed? Explain your answer. int i = 5; int j = i++;
4 Answers
+ 5
i = 6
j = 5
0
j=5 and i=6 now do you understandđ.
0
I=6 j=5 because i++ first assign then valu of i to j and then it will incremwnt the value of i
i++ increments the variable after it is used
- 1
i = 5, j = 5
Pre-incrementation (++i) increments the variable before it is used.
Post-incrementation (i++) increments the variable after.