+ 2
About increment in for loop
why always in the inctemebt of the for loop we use the postfix x++ and not prefix ?..although they have the same result
2 Answers
+ 1
It doesn't make any difference, both of them are correct. The difference in prefix and postfix is important when you assign values (i.e., y=x++ and y=++x are different things), but it makes no difference if what you execute is just a bare "x++" or "++x", as in the for loop case.
I think that "x++" in for loops is just more "traditional", but I've seen people using "++x" as well.
+ 1
In theory, prefix is actually a (very) bit faster, so you should rather focus on that rather than the tradition.
But it the performance gained is not significant so only Pros care about it. :D