+ 2
Different between while loop and for loop
Hello
3 ответов
+ 2
A for loop is better used for a repeative action you want to happen a certain amount of times.And the while loop is better at repeating an action until an event or a condition is met.
+ 1
A while loop executes a block of code as long as the specified condition remains true. So if I use 2 constants in the condition, the loop will run forever, e.g: while (1==1). A for loop on the other hand requires a startong value for the condition variable, a value with which to increment, and a termination value.
+ 1
Good thanks