0

what does this mean" total+=number"

28th Jul 2016, 4:31 AM
Prabhat
3 Answers
+ 3
Lets says total=5; number=3; total+=number is same as 5+3 and the value is stored in the variable total. total+=number implies total=total+number
28th Jul 2016, 5:00 AM
chaitanya guruprasad
chaitanya guruprasad - avatar
+ 3
"total += number" is sort form of "total = total + number" example: "int a = 5, b = 3; b += a; cout<<b;" output: 8 explanation: "b +=a" => "b = b + a" => "b = 3 + 5" => "b = 8" thanks
28th Jul 2016, 5:03 AM
Preetam Daila
Preetam Daila - avatar
+ 1
"total+=number" it's shorthand to "total=total+number"... both expressions do exactly the same and are equivalent in your code.. For easier readability of your code, it's recomended the shorthand version. Hope it helped
28th Jul 2016, 10:26 AM
Nelson Urbina
Nelson Urbina - avatar