increment a loop | SoloLearn: Learn to code for FREE!


increment a loop

why is that when you use x++ in the for-loop during incrementing gives a different result unlike using x+1.

9/12/2019 5:43:08 PM


3 Answers

New Answer


x+1 doesn't increase the value of the variable x. ++x does. So when your loop depends on x increasing, the first method wouldn't give you what you want.


Can you post an example?


x+=1 increments the loop