Next: Using the Loop Variable
Up: DO Loop Basics
Previous: The Power of Looping

DO Loop Syntax

A standard Fortran 77 DO loop looks something like this:

      DO 10 I = 1, 100
        STATEMENT
        STATEMENT
        STATEMENT
10    CONTINUE

Thus, the first statement of the loop contains a number following the keyword DO, and the last statement of the loop is labeled with that number. This is the form that DO loops take in the text.

In most Fortran 77 compilers, as well as in all Fortran 90 compilers, the following way of defining a DO loop is possible:

      DO I = 1, 100
        STATEMENT
        STATEMENT
        STATEMENT
      ENDDO

Here, there's no number following the keyboard DO, and the end of the loop is indicated with an ENDDO statement. This form is easier to use because you don't have to fool around with labeling statements with numbers. We'll use this form of the syntax in our examples, and you should use it in your programs as well.


Next: Using the Loop Variable
Up: DO Loop Basics
Previous: The Power of Looping

Hamlet Project
hamlet@cs.utah.edu