next up previous contents
Next: Language Elements Up: Fortran 90 Programming Previous: Fortran 90 Programming

Example

Example Fortran 90 program:

    PROGRAM Triangle
     IMPLICIT NONE
     REAL :: a, b, c, Area
     PRINT*, 'Welcome, please enter the&
              &lengths of the 3 sides.'
     READ*, a, b, c
     PRINT*,'Triangle''s area: ',Area(a,b,c)
    END PROGRAM Triangle
    FUNCTION Area(x,y,z)
     IMPLICIT NONE
     REAL :: Area       ! function type
     REAL, INTENT( IN ) :: x, y, z
     REAL :: theta, height
     theta=ACOS((x**2+y**2-z**2)/(2.0*x*y))
     height=x*SIN(theta); Area=0.5*y*height
    END FUNCTION Area

For more information, click here gif


next up previous contents
Next: Language Elements Up: Fortran 90 Programming Previous: Fortran 90 Programming

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