What is the simple diffrnce between For , while and do while loop ? I mean major Answer I want .. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the simple diffrnce between For , while and do while loop ? I mean major Answer I want ..

regarding loop

13th Jul 2016, 11:03 AM
Vinod Bahadur Thapa
Vinod Bahadur Thapa - avatar
4 Answers
+ 2
syntax: 1. while(condition) statement 2. do statement while (condition) 3. for (declaration; condition; last statement on each iteration) statement as you can see on the syntax above. 1. While loop check the condition first, and then run the statement, and the loop continues 2. Do while loop run the statement first, and then check the condition, and the loop goes on like that 3. For loop allows you to declare a variable and put a last statement on each iteration.
13th Jul 2016, 12:18 PM
Firdaus Al-Ghifari
Firdaus Al-Ghifari - avatar
+ 1
While means entry and do while means exist and for means checking the true or false value
13th Jul 2016, 1:39 PM
Manickam.D
Manickam.D - avatar
+ 1
1 while loop is an entry control loop whereas do while is an exit control loop. 2 in while loop after while no semicolon is used whereas in do while after while semicolon is used. 3 syntax do statement while (condition) for (declaration; condition; last statement on each iteration) statement
13th Jul 2016, 2:17 PM
Ritik Jaiswal
Ritik Jaiswal - avatar
0
the difference between a while and a do while is that you can enter a first try in the loop on the do while even if the condition is false, but you can't do that on the while, in the while you need the condition to be always true. the difference between these two and the for is that the for is more flexible, we know from the beggining what go in last kn the loop and what will beggin with, you're not forced to put that in the for bu if you don't it's equal to a while
14th Jul 2016, 5:41 PM
André Marques
André Marques - avatar