+ 2
What is the difference between For and While...? Looks and works exactly same...!
2 Réponses
+ 6
They work similar, but have definite differences. The For-Loop allows specifics with iteration through the loop variable and is great to use when you know exactly how many times you want the code to iterate. The For-Loop checks statement1 for info, checks statement2 to see if statement1 is true, executes the code, and THEN applies statement3 to its parameters. While-Loops will simply execute the code over and over as long as the condition is true.
0
For - for as long as,
While - while condition is, do 1 2 3 4.
so the 2 loops are different.