Today i got cleared of a very big misconception about Compound assignment operators.
I had wrongly understood statements like
A -=b+c as A=A-b+cBut correct is A -=b+c is same as A = A – (b+c)
More explanation can be find here
I have built this wrong concept because in elementary C books there was rarely mentioning of three variables for compound assignment operator examples. Like
The last example(bottom) below i never came through 😦
expression |
evaluation |
---|---|
value += increase; |
value = value + increase; |
a -= 5; |
a = a - 5; |
a /= b; |
a = a / b; |
price *= units + 1; |
price = price * (units + 1) |
Recent Comments