Whats the difference between these 3 while loops ... Check the code and comments for more | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Whats the difference between these 3 while loops ... Check the code and comments for more

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

6th Jun 2018, 10:45 AM
Sachin Bhatt
Sachin Bhatt - avatar
2 Answers
+ 1
First of all. In the second while loop, you're wrong in the comment, it's not from 20-26, but it's from 21-26. Why the first differ from second? simply because in the first while loop you increment after output the value. while on the second you increment before output the value. when the first while loop the variable i reach 25, at the end of the loop the value of i actually 26. but you dont output the value, that's why only 20-25. and the third while loop needs no explanation, you should understand that, it's basic , it's increment the value to the end of the loop, then output the value.
6th Jun 2018, 5:10 PM
Owenizedd
Owenizedd - avatar
0
thnx
7th Jun 2018, 12:59 PM
Sachin Bhatt
Sachin Bhatt - avatar