How does += operator works?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How does += operator works??

2nd Jul 2017, 8:13 AM
Parth Dhake
Parth Dhake - avatar
5 Answers
+ 21
+= is a short version for addition x+=y means x=x+y i.e the value of x gets increased by adding y to it.. Similarly other operations can be *= , -= , /=, %= You can refer the chapters in the course, if not understandable you can view the comments posted there so as to get a clear picture about it...
2nd Jul 2017, 8:20 AM
Frost
Frost - avatar
+ 3
imagine a function call with infix notation just like any other infix operator like +,-,.,*. it gets expanded from x+=y to x = x + y.
2nd Jul 2017, 8:20 AM
Venkatesh Pitta
Venkatesh Pitta - avatar
+ 2
short version fr sum of two num to be stored in one of the variables. for examples x+=y...is same as x=x+y... hope you got it
2nd Jul 2017, 10:39 AM
DEVIL kingg
DEVIL kingg - avatar
+ 2
a=a+b; can be shortly expressed as a+=b;
2nd Jul 2017, 4:36 PM
Jatin Agarwal
Jatin Agarwal - avatar
+ 1
a+=b and a-=b are short forms for a=a+b and a=a-b respectively. Actually it has emphasis on the variable which is 'a' and is being manipulated (plus or minus) as 'b'. Therefor it seems logical to shorten it in this way. Hope it helps
2nd Jul 2017, 9:34 PM
Mahyar Ahmadpour
Mahyar Ahmadpour - avatar