+ 3
what does x-=2 mean?
8 Respostas
+ 7
it means x=x-2;
+ 3
It actually a shorthand method of writing x = x - 2. It holds good with other arithmatical operators too.
+ 2
Like Rohan Yadav said just subtract 2 from x and then reassign it to x so that the value of x becomes 2 less than what it was before. In a loop it will continue decreasing the value over each iteration until a condition is met and the loop is dropped out of.
+ 2
Yes, it's the sort hand for. x = x-2
you can also use:
x += 2. for addition
x *= 2. for multiplication
x /= 2. for division
x ℅=2. for modulus
x **=2. for power x^2
+ 1
is it a condition for a loop? If yes the loop will stop when x is 0.
+ 1
x = x-2
0
+Rohan Yadav, does that mean that when the outputed number-x equals 2, the loop will stop?
0
It is same as x = x + 2