Where is it benificial to use while loop instead of for loop in any language? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Where is it benificial to use while loop instead of for loop in any language?

I came across some programs where i think using while loop was more relevant. But they do the same task..can someone tell me the practical difference between the both

5th Nov 2017, 11:15 AM
Siddhant Parashar
Siddhant Parashar - avatar
1 Answer
+ 1
You use a for loop, when you know how many times you want to loop your code. Whereas you use a while loop when you don't know how many times you want to run your loop..... Hope this makes sense..
5th Nov 2017, 11:19 AM
Cool Coder
Cool Coder - avatar