+ 1

Two different code but the same result , why?

https://code.sololearn.com/ci3v8Mn9Ycw2/?ref=app

2nd Nov 2021, 7:08 PM
‎محمد نور درويش بوشي‎
‎محمد نور درويش بوشي‎ - avatar
3 odpowiedzi
+ 4
Do you think they should have a different result? If so, why?
3rd Nov 2021, 2:31 AM
Paul K Sadler
Paul K Sadler - avatar
+ 2
I think you are asking why it gives the same outcome regardless of using prefix or postfix incrementing at the end of the for() loop. In this context the values of i and j are not used at the time they are incremented. They are just incremented. Regardless of incrementing before or after evaluation or use, in the end they both are still incremented. You might want to review C++ lesson 9.1 prefix and postfix incrementing https://www.sololearn.com/learning/1610/
2nd Nov 2021, 8:48 PM
Brian
Brian - avatar
0
Different codes can yield the same outputs. Please link your codes.
2nd Nov 2021, 7:38 PM
Lisa
Lisa - avatar