+ 1

what's the difference between the ++ten and ten++ when you increment taking ten as a variable that I'm incrementing? ??

increment

21st Sep 2016, 1:19 PM
Aphile Kondlo
Aphile Kondlo - avatar
5 Answers
+ 2
it is most helpful when you assign it.. for eg. ten=10 and if you wish to assign this to variable 'x' then ++ten will result in ×=11 as well as ten=11.. ++ten increments first and then assigns.. while ten++ will result in x=10 and ten=11.. ten++ will assign first and then increments
27th Sep 2016, 5:37 AM
Aditi Deshmukh
Aditi Deshmukh - avatar
+ 1
ten++ and ++trn both will give same output 11. Difference is ++ten will give output immediately..i.e on same line But ten++ will be 11 from next line onwards...
21st Sep 2016, 5:37 PM
Shubham Bhangale
Shubham Bhangale - avatar
+ 1
++ten in pre-increment while ten++ is post increment.
3rd Oct 2016, 12:54 AM
Daniel Ani
Daniel Ani - avatar
+ 1
https://code.sololearn.com/c68JVx3xS9B0/?ref=app Check this. It is self explanatory. It might be helpful for you
15th Feb 2017, 1:37 PM
Kommoju Sunil Kumar
Kommoju Sunil Kumar - avatar
0
int a = 5; int b; b = a++; b = ++a; in line 3 first b = a than a = a+1 result : b = 5 , a = 6 in line 4 first a = a + 1 than b = a result : a = 6 , b = 6
23rd Feb 2017, 9:27 AM
Ali
Ali - avatar