+ 1

What i = i + 1 does in this code?

I can't really get what i = i + 1 does here.

3rd Feb 2017, 8:47 PM
Mateo
6 odpowiedzi
+ 7
another way of writing this is: i += 1 also you can use another operators instead of "+". for example: i = 2 i *= 3 now i is 6.
3rd Feb 2017, 8:58 PM
Saeed Amiri
+ 4
This is absolutely great for scores in games--it takes a variable and adds the number 1 (or any number you'd like) to it. Also, in some languages this is abbreviated to be i++, like C++ does.
3rd Feb 2017, 9:11 PM
Jeremie
Jeremie - avatar
+ 3
for example i = 1 i = i + 1 i is 2 now so its just increase i :)
3rd Feb 2017, 8:50 PM
R4xx4r
R4xx4r - avatar
+ 3
It increases the value if I every time it executes.
4th Feb 2017, 4:12 PM
Sunnykant Tiwari
Sunnykant Tiwari - avatar
+ 2
Thank you!
3rd Feb 2017, 8:51 PM
Mateo
0
i is assigned the value of itself and then adds 1 to that value and assigns that new value to i
4th Feb 2017, 5:12 AM
Tudor Anghelina
Tudor Anghelina - avatar