0

What is the difference between "i =i+1" and "i +=i?

3rd Jan 2020, 11:08 AM
Jayaraj Rajendren
Jayaraj Rajendren - avatar
3 Respuestas
+ 10
there is a big diffrence i=i+1 means i equals the current value of i and then increments it by 1 so the value of i if it's current value is 10 would now equal the value of 11. i+=i means the i now adds its current value to its self so let's say i equals 10 using this += expression the value of i will now equal 20 because you just added 10 to its self. i+=1 does the same as i=i+1 there both incrementing the current value of i by 1.
3rd Jan 2020, 11:15 AM
D_Stark
D_Stark - avatar
0
Do you mean "i += 1"? If so, then there's no difference.
3rd Jan 2020, 11:10 AM
CapCode
0
Then i+=i means
3rd Jan 2020, 11:12 AM
Jayaraj Rajendren
Jayaraj Rajendren - avatar