+ 1

May I know why we are getting same when we put put pre increment instead of post increment

15th Jul 2020, 4:18 PM
Venkata Krishna Naga Sai
Venkata Krishna Naga Sai - avatar
4 odpowiedzi
+ 1
In a loop, counter increment does not concern whether the counter is pre or post incremented. What counts more (and oftenly skipped or forgotten somehow) is the counter not being incremented/decremented, causing the loop to be infinite.
15th Jul 2020, 4:41 PM
Ipang
+ 1
Thanks
15th Jul 2020, 4:42 PM
Venkata Krishna Naga Sai
Venkata Krishna Naga Sai - avatar
+ 1
No problem 👌
15th Jul 2020, 4:42 PM
Ipang
0
It's not the same: https://code.sololearn.com/cgYeI9eYRrCX/?ref=app But the use cases are rare. Sometimes it's more about the performance, especially within very large loops you should prefer the pre-increment.
15th Jul 2020, 4:51 PM
Sandra Meyer
Sandra Meyer - avatar