0

i don't understand

x += y-- how does it work ??

4th Sep 2020, 1:32 PM
blind magnet
blind magnet - avatar
7 Respostas
+ 7
plus equal can you also write like that: x = x + y-- the double minus after the y means y minus one after the assignment, so it doesn't affect y in the assignment of x here. It just affect y after the assignment. For example when x = 5 and y = 3 x = 5 + 3 = 8 but after 8 is assigned to x, y is decremented by one, so: y = 2 to understand the double minus (which is called decrement) you can read here: https://www.baeldung.com/java-unary-operators
4th Sep 2020, 1:57 PM
David
+ 4
x += y-- means x =x+ y y ofter Double -- are post increment means For example x=2,y=5 x = 2 + 5 = 7 -- it will decrement the y value ofter assignment Means y value become 6 see this sections in assignments , increment and decrement operators https://www.sololearn.com/learn/C/2917/
4th Sep 2020, 3:58 PM
Bhargava Ram
Bhargava Ram - avatar
+ 2
yes at last y decrement
4th Sep 2020, 2:03 PM
blind magnet
blind magnet - avatar
+ 1
🎸🎸🎸 oops sorry. Thanks for correcting
4th Sep 2020, 2:11 PM
XXX
XXX - avatar
+ 1
Ah yes, forgot to mention y in that example, now I added it
4th Sep 2020, 2:12 PM
David
0
x is incremented by y and then y is decremented by 1
4th Sep 2020, 1:54 PM
XXX
XXX - avatar
0
thanks for responding ❤️
4th Sep 2020, 1:58 PM
blind magnet
blind magnet - avatar