Loops/While: Difference between revisions

Line 509:
GOTO 10
ENDIF
STOP
END</lang>
 
{{works with|Fortran|IV and 66 and later}}
C This is an alternative while loop with labels on both ends. This
<lang fortran> PROGRAM LOOPWHILE
C will use the condition as a break rather than create an entire
INTEGER I
C IF block. Which you use is up to you, but be aware that you must
C FORTRAN 66 does not have IF block.
C use this one if you plan on allowing for breaks.
I = 1024
20 10 CONTINUE
C IF (I .LE. If0) conditionGOTO is false, break.20
IFWRITE (I .LE. 0*,*) GOTO 30I
C I = I Handle/ I.2
GOTO WRITE (*,*) I10
30 20 CONTINUE
I = I / 2
STOP
C Jump back to the "loop" beginning.
GOTO 20
30 CONTINUE
 
STOP
END</lang>
 
1,392

edits