Difference between for loop, while loop and do while loop. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Difference between for loop, while loop and do while loop.

difference between 3 loops

29th Nov 2017, 4:21 PM
MOHAN ARVIND K
MOHAN ARVIND K - avatar
1 Answer
+ 6
The main difference between for loop, while loop, and do while loop is While loop checks for the condition first. so it may not even enter into the loop, if the condition is false. do while loop, execute the statements in the loop first before checks for the condition. At least one iteration takes places, even if the condition is false. for loop is similar to while loop except that initialization statement, usually the counter variable initialization statement that will be executed after each and every iteration in the loop, usually counter variable increment or decrement
29th Nov 2017, 4:32 PM
Md. Nafis Ul Haque Shifat
Md. Nafis Ul Haque Shifat - avatar