0
i don't understand
x += y-- how does it work ??
7 Respuestas
+ 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
+ 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/
+ 2
yes at last y decrement
+ 1
🎸🎸🎸 oops sorry. Thanks for correcting
+ 1
Ah yes, forgot to mention y in that example, now I added it
0
x is incremented by y and then y is decremented by 1
0
thanks for responding ❤️