Fortran: Lesson 4

Lesson topics


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

Demo 1

								        program annulus
c       This program calculates the area of an annulus.
c       The inner and outer radii are input by the user.
c       A statement function for the area of a circle is used.
        double precision r, area, pi, a, b
        parameter (pi = 3.1415926535897932D0)
        area(r) = pi * r * r
        print *, "Enter the inner and outer radii of the annulus:"
        read *, a, b
        write (*,10) "Area of the annulus: ", area(b) - area(a)
 10     format (a,f25.15)
        end