+ 2

Different between while loop and for loop

Hello

25th Jan 2017, 7:58 PM
IBRAHIM SULE UDI 🇳🇬
IBRAHIM SULE UDI 🇳🇬 - avatar
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.
25th Jan 2017, 8:43 PM
Denis Angelov
Denis Angelov - avatar
+ 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.
25th Jan 2017, 8:23 PM
denzal maradona
denzal maradona - avatar
+ 1
Good thanks
25th Jan 2017, 8:56 PM
IBRAHIM SULE UDI 🇳🇬
IBRAHIM SULE UDI 🇳🇬 - avatar