+ 3

What is x+= ?

int x = 0; x+=3; It's x + 3? And the x is a result?

21st Dec 2017, 2:14 AM
Tennouji Kotarou
Tennouji Kotarou - avatar
5 Answers
+ 13
It is a shorthand version of: x = x + 3 So then if x = 1 x = x + 3 equals 4.
21st Dec 2017, 3:37 AM
Learnsolo
+ 13
it is short hand of x = x + 3 if x = 0 and x = x + 3 then x = 3
21st Dec 2017, 2:20 AM
jay
jay - avatar
+ 9
Just to add to James answer about increment operators (?), they are ++ and -- If you need to read more about them, you can find information here. https://en.m.wikipedia.org/wiki/Increment_and_decrement_operators
21st Dec 2017, 2:31 AM
jay
jay - avatar
+ 7
Just a cautionary note, sometimes the pre and post increment operators can have unexpected results and what does: x[i]=i++ + 1; do Read here:http://www.angelikalanger.com/Articles/VSJ/SequencePoints/SequencePoints.html
21st Dec 2017, 2:25 AM
James16
James16 - avatar
0
x+=2
29th Jun 2020, 12:20 PM
ŠŠøŠŗŠøтŠ° Š¤Š¾ŠŗŠø
ŠŠøŠŗŠøтŠ° Š¤Š¾ŠŗŠø - avatar