Fortran: Lesson 5

Lesson topics


View Demos
# 1 # 2 # 3
Download Demos
# 1 # 2 # 3

Demo 1

								        program demofactorial
c       This program evaluates factorials. The user inputs an integer, 
c       and a function subprogram computes its factorial.
        integer fact, n
        print *, "What is your integer n?"
        read*, n
        print *, "The value of", n, " factorial is", fact(n)
        print *, "See you!"
        end

        function fact(n)
        integer fact, n, p
        p = 1
        do i = 1, n
                p = p * i
        end do
        fact = p
        end