with command `mplayer -loop number-of-repeatsfilename`
if number-of-repeats is set to 0, the movie would loop for ever.
odd loop means at least the loop execute once.
The for loop would execute 10 times in the following code snippet.
The do-while loop is designed specifically for such situations, where you want the loop to execute once irrespective of the loop expression. The loop would execute once and then terminate because, the loop controlling expression is false. If you note the syntax properly do { ... ... ... } while(condition) The condition is executed only after one iteration of the loop and hence the code would execute once irrespective of the loop expression result.
Both are programming commands. A do/while loop will execute at least once. A while loop may not execute at all.
1) use for loop 2) do while loop
count-controlled
for loop and while loop need the expression to be true for further execution of the program.
A do-while loop guarantees the body of the loop will execute at least once. A while loop might not execute at all. // this code will execute, even though the condition test will always evaluate to false do { // stuff }while(false); // this code will never execute because the condition test will always evaluate to false while(false) { // stuff }
A DO-WHILE loop will always execute at least one iteration of the loop body. This is because the condition that controls the loop comes at the end of the loop, rather than at the beginning as per a WHILE or FOR loop.
A loop check is a condition that is checked everytime a loop is executed. It is usually the condition that needs to match for the loop to terminate. Until this condition is matched the loop will continue to execute. Ex: for(int i=0; i<10; i++) { … } In the above for loop "i<10" is the loop check condition and this loop will execute until the value of i is less than 10. It starts at 0 and gets incremented by 1 everytime the loop completes an iteration of execution
A loop check is a condition that is checked everytime a loop is executed. It is usually the condition that needs to match for the loop to terminate. Until this condition is matched the loop will continue to execute. Ex: for(int i=0; i<10; i++) { … } In the above for loop "i<10" is the loop check condition and this loop will execute until the value of i is less than 10. It starts at 0 and gets incremented by 1 everytime the loop completes an iteration of execution
For LOOP is used, when you want to execute a specific block of code for specific number of times.