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 3

								c       This program demonstrates the "if - then - else" construction.
c       The "if" line ends with "then".
c       Also, "else" must go on a line by itself.
        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
        else
                print *, "Your number has no real square root."
        end if
        print *, "Bye"
        end