0
How can I know when to use for loop and when to use while or do while
2 Answers
+ 4
In many cases you can decide that freely, however
* for loop when it need to run a fixed number of times that is certain before you start the loop
* while loop when it needs to run a fixed or unknown number of times
* do while: similar to while loop but it needs to run minimum once
0
* Recursion: inefficient and difficult to understand loop in which a function calls itself jaja