+ 3
Please explain '+=' statment
6 Respuestas
+ 17
x+=a --> x=x+a
x-=a --> x=x-a
x*=a --> x=x*a
x/=a --> x=x/a
x%=a --> x=x℅a
x^=a --> x=x^a
+ 4
int x = 4;
x += 4; // Adds 4 to x and assigns that value to x.
// same as:
x = x + 4;
+ 1
'a += b' is technically equivalent to 'a = a + b'. It's basically a faster way to write code that sums values and adds them to an existing variable.
+ 1
it is just shorthand of x=x+
+ 1
a+=b is similar to a=a+b;
- 1
x+=1 means x = x + 1
for example 5+=1 means (5 = 5+1) = (5+=1)
simple maths 🙂