Differences of WHILE, DO-WHILE, FOR loop | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Differences of WHILE, DO-WHILE, FOR loop

can someone briefly explain the main differences of the WHILE, DO-WHILE and FOR loop, thanks in advance!

15th Nov 2017, 8:55 AM
A.J. Velasco
A.J. Velasco - avatar
2 ответов
+ 5
[while loop] Performs evaluation of the condition prior to execution of the loop body [do.. while loop] Executes the loop body prior to evaluation of the condition, usually, one iteration is carried out before the condition is evaluated. [for loop] Consists of initial condition, final condition (defines when loop should stop), and action (what to do on each iteration that changes the condition to shift closer to, and eventually reach, the final condition) Hth, cmiiw
15th Nov 2017, 9:29 AM
Ipang
+ 8
while executes a block of code while the condition is true. do-while is like while but it executes the block of code before checking the condition. for is like while but you can initialize and increment/decrement variables in it's parentheses.
15th Nov 2017, 9:28 AM
qwerty
qwerty - avatar