014. if-else if-end if block#

topic: Conditionals

if-block.f90 | | Godbolt Compiler Explorer logo | Fortran logo#
integer :: i

do i = -1, 1
   print *, i
   if (i < 0) then
      print *, "negative"
   else if (i == 0) then
      print *, "zero"
   else
      print *, "positive"
   end if
end do

end
Output1#
          -1
 negative
           0
 zero
           1
 positive


1

Compiled using GNU Fortran (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0 with no flags