|1||Compound Assignment Operators Output|
|2||Arrange such that a is 700 and b is 164|
|3||Arithmetic Operators Increment Decrement Compound Assignment Output|
|4||Arithmetic Operators Increment Decrement Compound Assignment Output36|
|5||Arithmetic Operators Incorrect statement|
|6||Arrange the lines of the code|
|8||Creating Variables and Arithmetic Operators|
Choose the incorrect statement about the following expressions?
Correct Answer : C
a = a + 1 increments value of a by
a++ (post increment) also is equivalent to expression
1. This statement also increments value of
a += 1 is equivalent to
a = a + 1. So it also increments
++a is called pre increment and it increments value of
Thus all expressions give same result i.e., all expressions increment value of
1. Post increment is faster than
a += 1 since in
a += 1, we will have to take the value of
a, add one to it, and then store the result back to
a++ will be a single assembly instruction. So
a++ is faster than
a += 1.
NOTE: Pre increment is more efficient than post increment, because for post increment the object must increment itself and then return a temporary containing its old value.