What will i and j equal after the code below is executed? Explain your answer. int i = 5; int j = i++; | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What will i and j equal after the code below is executed? Explain your answer. int i = 5; int j = i++;

8th Sep 2016, 6:25 PM
Aklil Asregid
Aklil Asregid - avatar
4 Answers
+ 5
i = 6 j = 5
8th Sep 2016, 8:41 PM
Cohen Creber
Cohen Creber - avatar
0
j=5 and i=6 now do you understand😉.
10th Dec 2016, 3:16 PM
Anand Chourasiya
Anand Chourasiya - avatar
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
28th Feb 2018, 1:13 PM
Dhruti kalariya
Dhruti kalariya - avatar
- 1
i = 5, j = 5 Pre-incrementation (++i) increments the variable before it is used. Post-incrementation (i++) increments the variable after.
8th Sep 2016, 6:31 PM
Zen
Zen - avatar