* * Program enddo - demonstrate how the END DO FORTRAN extension * works. * * Written by: Charles Severance - 10Mar92 * integer I * * Using the ENDDO it is not necesssary to specify a statement label * on the DO statement. This makes code look much cleaner. * PRINT *,'Starting a DO LOOP...' DO I=1,10 PRINT *,'I=',I ENDDO PRINT *,'Done with the DO LOOP' * * It is also possible to nest DO loops using the END DO statement. * FORTRAN matches the DO and END DO from the inside out. * PRINT *,'Starting the second DO LOOP' DO I = 1,5,2 PRINT *,'I=',I DO J=50,70,10 PRINT *,I,J ENDDO ENDDO PRINT *,'Done with the second DO LOOP' END $ a.out Starting a DO LOOP... I= 1 I= 2 I= 3 I= 4 I= 5 I= 6 I= 7 I= 8 I= 9 I= 10 Done with the DO LOOP Starting the second DO LOOP I= 1 1 50 1 60 1 70 I= 3 3 50 3 60 3 70 I= 5 5 50 5 60 5 70 Done with the second DO LOOP