Fortran: Lesson 2

Lesson topics


View Demos
# 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10
Download Demos
# 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10

Demo 4

								c       Here we demonstrate the "if - then - else if" construction.
c       The "if" line ends with "then".
c       Likewise, every "else if" line ends with "then".
        program sign
        real x
        print *, "What is your number ?"
        read *, x
        if (x .gt. 0) then
                print *, "Your number is positive."
        else if (x .lt. 0) then
                print *, "Your number is negative."
        else if (x .eq. 0) then
                print *, "Your number is neither positive nor negative."
        end if
        print *, "Bye"
        end