Notice

YouTube.com/BESTTravelers - Visit and SUBSCRIBE to our travel related YouTube Channel named "BEST Travelers"

Monday, March 7, 2011

Difference between i++ and ++i



Most programmers become confused regarding the difference between i++ and ++i. Please see the example to clear your conception. 

i = 5;
j = ++i;
Answer: i=5, j=6 (So ++i increase value of i and return incremented value)

i = 5;
j = i++;
k = i;
Answer: i=5, j=5, k= 6 (i++ increase value of i. But did not return incremented value. But incremented value will be received from next line of code)

No comments:

Post a Comment