| ! -- program to determine least of three given values :
PROGRAM least_of
REAL :: first, second, third
REAL :: least
WRITE(UNIT=*, FMT=*) 'Enter three values...'
READ(UNIT=*, FMT=*) first, second, third
least = min(first, second)
least = min(least, third)
WRITE (UNIT=*, FMT=*) 'Least of the three numbers is: ', least
END PROGRAM least_of
! -- subprogram returns a if a is less than b, otherwise returns b :
FUNCTION min(a, b)
REAL, INTENT(IN) :: a, b
REAL :: min
IF (a < b) THEN
min = a
ELSE
min = b
END IF
END FUNCTION min
|