FORTRAN PROGRAMS
FORTRAN PROGRAMS
Function Fact( K )
Integer :: K, L
Real :: M, Fact
If( K = 0) Fact = 1.0
If ( K /= 0) then
M = 1.0
L=1
Doloop1: DO
M = M * (M + 1.0)
L=L+1
If( L >= K) exit Doloop1
Enddo Doloop1
Fact = M
Endif
End Function Fact
EXAMPLE 11 Reading the name of the month and printing the first three characters.
! Program to read the name of a month and print only the first three characters
Program print_month
Implicit none
Character(len=15) :: month
Print *, ‘Please Type a month’
Read(*,”(a15)”) month
Write(*, “(1x, ‘First three character of the Month is’, 1x, a3)”) month( : 3)
End program print_month