FORTRAN Lesson 3
FORTRAN Lesson 3
if..elseif Statement:
if (logical expression) then
statements
elseif (logical expression) then
statements
:
:
else
statements
endif
program ex9
integer :: a, b, c
write (*,*) 'Enter three integer number:'
read (*,*) a, b, c
if ((a .GT. b) .AND. (a .GT. c)) then
write (*,*) a, ' is MAX'
elseif ((b .GT. c) .AND. (b .GT. a)) then
write (*,*) b, ' is MAX'
elseif ((c .GT. a) .AND. (c .GT. b)) then
write (*,*) c, ' is MAX'
else
write (*,*) 'Three numbers are equal'
endif
end program ex9
Nested-if Statement:
!Program to Check Leap Year
program ex10
integer :: yr
read (*,*) yr
else
endif
else
endif
else
endif
program ex11
integer :: a, b, choice
read (*,*) a, b
case (1)
case (2)
write (*,*) 'Difference=',(a-b)
case (3)
case (4)
case default
end select