English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

3 answers

more rigorous compared to what????
actually all loops are equal in terms of computer

ie for while do while
dosent make difference
if all 3 execute the same body same number of times....

if u r comparing do while to some other thing pls specify

2007-12-28 09:07:37 · answer #1 · answered by heyyy 2 · 0 0

Rigorous in terms of making it work?

A For/Next will execute a finite number of times and drop out of the loop.
For X = 1 to 10

Next X

However a Do/While Loop Or Loop While loop needs to determine when to exit the loop by determining if an exit condition becomes true.

Do While X < 10
X+=1 ' This may not execute because X could already be >10
Loop

or

Do
X +=1 ' this always executes before the While Test
Loop While X < 10

It is possible that a Do While loop can loop endlessly if and exit condition is not provided in the data or in the program code. ( Error , or omission or otherwise). If you are reading a file and are using its data to determine an exit point you would have and endless loop if the trigger data is missing in the file for example

To prevent endless looping some additional overhead may be provided by the programmer such as adding multiple conditions for exiting the loop. Also a loop counter may be added and used as a means of exiting a Do/While if an excessive number of loops have been made.

X=0
Do

Data = 'some string from a text file
'Do stuff with Data like load an array etc
X+=1 ' Count passes through loop
Loop While X < 100 OR Data = "END"

2007-12-28 17:36:20 · answer #2 · answered by MarkG 7 · 1 0

a do while will execute once, where a while will not. But I dont know what you mean.....

2007-12-28 17:21:31 · answer #3 · answered by ? 6 · 0 0

fedest.com, questions and answers