next up previous contents
Next: SELECT CASE Construct Up: Control Flow Previous: Examples of Loop Counts

Scope of DO Variables

  1. I is recalculated at the top of the loop and then compared with tex2html_wrap_inline43037  expr2 tex2html_wrap_inline43039 ,
  2. if the loop has finished, execution jumps to the statement after the corresponding END DO,
  3. I retains the value that it had just been assigned.
For example,

    DO i = 4, 45, 17 
     PRINT*, "I in loop = ",i
    END DO
    PRINT*, "I after loop = ",i

will produce

    I in loop =  4
    I in loop =  21
    I in loop =  38
    I after loop =  55

An index variable may not have its value changed in a loop.

For more information, click here gif


next up previous contents
Next: SELECT CASE Construct Up: Control Flow Previous: Examples of Loop Counts

Adam Marshall ©University of Liverpool, 1996
Fri Dec 6 18:56:08 GMT 1996
Not for commercial use.