0
what is the difference between ++test and test++.
hello ++test and test++ gives the same answer but what is the difference between them???
2 Réponses
0
increments when is before it will increase the value by one and if is after it will increase after.
0
++test is the prefix to incrementation
test++ is the postfix to incrementation
Here is the logic.
++ actually means adding 1.
++test is 1+ test.
test++ is test + 1.
The value to the prefix changes first because it hits the increment before it gets to the original variable which is test.
(1+)test.
The value of the postfix changes after because it hits the original variable first before it gets to increment.
(test)+1.