C Author: Mitch Richling<http://www.mitchr.me/>
C IP: Copyright 1993 by Mitch Richling. All rights reserved.
C Key word: FORTRAN f77 do
C Notes: Illustrates two common goto replacements for
C repeat-until (do-while) and while-do type
C loops. This kind of thing is still commonly
C found in working code.
C LOOPS with Goto
program loopsg
real X
write (*,*) 'Typical "while-do" loop idiom.'
X = 5
100 if (X .ge. 2) then
write (*,*) 'X=', X
X = X - 1
goto 100
endif
write (*,*) 'This is a typical "do-while" construct.'
X=5
400 continue
X = X - 1
write (*,*) 'X=', X
if (X .ge. 3) goto 400
write (*,*) 'This is a typical "repeat-until" construct.'
X=5
500 continue
X = X - 1
write (*,*) 'X=', X
if (X .le. 0) goto 550
goto 500
550 continue
write (*,*) 'This is another typical "while-do" idiom'
x=5
600 if (X .le. 0) goto 650
write (*,*) 'X=', X
X = X - 1
goto 600
650 continue
end
Generated by GNU Enscript 1.6.5.2.