+ 1
what's the difference between the ++ten and ten++ when you increment taking ten as a variable that I'm incrementing? ??
increment
5 ответов
+ 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
+ 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...
+ 1
++ten in pre-increment while ten++ is post increment.
+ 1
https://code.sololearn.com/c68JVx3xS9B0/?ref=app
Check this. It is self explanatory. It might be helpful for you
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