do loop

views updated

do loop A counting loop in a program, in which a section of code is obeyed repeatedly with a counter taking successive values. Thus in Fortran,

    DO 10 I = 1,100

〈statements〉

10   CONTINUE

causes the 〈statements〉 to be obeyed 100 times. The current value of the counter variable is often used within the loop, especially to index an array. There are many syntactic variants: in Pascal and Algol-related languages the same basic construct appears as the for loop, e.g.

for i := 1 to 100 do

 begin

  〈statements〉

 end

This kind of loop is a constituent of almost all programming languages (except APL, which has array operations defined as operators in the language).

See also do-while loop.

More From encyclopedia.com