Why I obtain the same result if I write: for (i=..; i<..; i++) and for (i=..; i<..; ++i)? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why I obtain the same result if I write: for (i=..; i<..; i++) and for (i=..; i<..; ++i)?

In the for loop of c++ doesn't matter if I write i++ and ++i as increment? Because I obtained the same result even if I thought they were different.

24th Apr 2018, 11:08 PM
Leonardo
Leonardo - avatar
1 Answer
+ 4
You will see a difference were you to do: x=i++; vs. x=++i; as x would be assigned different values. But, there isn't a difference for: i++; vs. ++i; in both cases i ends up increasing by 1.
24th Apr 2018, 11:32 PM
John Wells
John Wells - avatar