+ 1

Why the output is different between these two code bits?

Why output difference is arised between these two code bits? please explain it why this change happen? When i replace a x++ increment position just before a "if loop" and just after a "if loop" that is nested inside a do...while ..loop Those two code bits just shown here below... https://code.sololearn.com/colbAcBaSFGN/?ref=app https://code.sololearn.com/cZ93g82oIW14/?ref=app

11th May 2020, 11:17 AM
Yogeshwaran
2 ответов
+ 1
1st code- x is incremented after the if condition so when x is 4, it is printed then the if condition is checked and the loop breaks. 2nd code- x is incremented before the if condition so when x is 3, it is printed and then incremented to 4 and then the if condition is checked and the loop breaks.
11th May 2020, 11:22 AM
Avinesh
Avinesh - avatar
+ 1
Avinesh bro now I understood bro
11th May 2020, 11:30 AM
Yogeshwaran