0
what does this mean" total+=number"
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
+ 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
+ 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