Fortran: Lesson 4

Lesson topics


View Demos
# 1 # 2 # 3 # 4 # 5 # 6
Download Demos
# 1 # 2 # 3 # 4 # 5 # 6

Demo 2

								        program demo
c       This program demonstrates the sign transfer function.
        real x, y
        print *, "What is your first number x ?"
        read *, x
        print *, "What is your second number y ?"
        read *, y

        print * 
        print *, "sign(x,y) = ", sign(x,y)
        print *
        if (sign(1,x) .ge. 0) then
                print *, "The sign of x is +"
        else
                print *, "The sign of x is -"
        end if
        if (sign(1,y) .ge. 0) then
                print *, "The sign of y is +"
        else
                print *, "The sign of y is -"
        end if

        print *
        if (sign(1,x) .eq. sign(1,y)) then
                print *, "x and y have the same sign"
        else
                print *, "x and y have opposite signs"
        end if
        print *
        print *, "Over and Out!"
        end