New course! Every coder should learn Generative AI!
Try a free lesson0
What's the difference between ++5 and 5++
4 Answers
+ 3
https://www.sololearn.com/discuss/252564/?ref=app
https://www.sololearn.com/discuss/155539/?ref=app
https://www.sololearn.com/discuss/176172/?ref=app
+ 2
++5 its pre-increment works like ( 1+5)
and
5++ its post-increment works like (5+1)
while
the resultant value of both will remain same as the answer of both are same (6).
0
a = 5;
b = ++a; //a = 6; b = 6, PRE increment, incremented before it's use
c =5;
d = c++; //c = 6; d = 5, POST increment, incremented after it's use