0
What is the simple diffrnce between For , while and do while loop ? I mean major Answer I want ..
regarding loop
4 Réponses
+ 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.
+ 1
While means entry and do while means exist and for means checking the true or false value
+ 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
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