0

what is the difference between ++test and test++.

hello ++test and test++ gives the same answer but what is the difference between them???

12th Dec 2016, 12:38 PM
Urvi Parekh
Urvi Parekh - avatar
2 Réponses
0
increments when is before it will increase the value by one and if is after it will increase after.
12th Dec 2016, 12:45 PM
Juan Madrigal
Juan Madrigal - avatar
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.
12th Dec 2016, 2:48 PM
Franky BrainBox
Franky BrainBox - avatar