+ 1
Need help with these codes
Can anyone explain the difference between code1 and code2 in https://code.sololearn.com/WYqYYBZ3gh2j/?ref=app and why is the output so much different when you just change the place of a curly brace?
3 Answers
+ 4
the first code u write 'i' for every loop, then write 'now i..' after the loop end once when i become 6..so output
1
2
3
4
5
now i = 6
the second code u write 'i' and 'now i..' for every loop..it should looks like this
1
now i = 1
2
now i = 2
3
now i = 3
4
now i = 4
5
now i = 5
but since u didnt put newline after 'now i',it is mixed
1
now i = 12 <-- 2 here is actually the start of second loop
+ 5
Lily Mea yes correct. I was going to write the same.đ.
It just concat the output.
https://code.sololearn.com/Wlqw8XnDPNsf/?ref=app
+ 3
Lily Mea and PâWAN MâURYâ Thanks for clearing up misunderstandings