+ 1
What is the difference between for loop and while loop? Are both loops irritation loops?
2 Réponses
+ 1
a while loop is usually used when you don't know or can't know until execution how many times your code is going to be executed. say you have a program that returns to a menu every time the person executes an action. you can't know how many times the person is going to be coming back to the main menu, so it's easier to use a while loop
0
a for loop is used to do something a certain number of times, our middle condition. a while loops is used to do something until a certain condition is met but we don't know how long it will take for that to occur