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 2

								c       Here we demonstrate the multi-line "if - then" construction.
c       The "if" statement ends with "then".
        program root
        real x, y
        print *, "What is your number ?"
        read *, x
        if (x .ge. 0) then
                y = sqrt(x)
                print *, "The square root of your number is : ", y
        end if
        print *, "Bye"
        end