next up previous contents
Next: Solution Up: Introduction to Fortran 90 Previous: Solution

 

Area Of a Circle

Write a simple program to read in the radius and calculate the area of the corresponding circle and volume of the sphere. Demonstrate correctness by calculating the area and volume using radii of 2, 5, 10 and -1.

Area of a circle,

equation1247

Volume of a sphere,

equation1250

Hint 1: place the READ, the area calculation and the PRINT statement in a loop as follows. A program template (which is available by clicking here) is given below.

 PROGRAM Area
  DO
   PRINT*, "Type in the radius, a negative value will terminate"
   READ*, radius
   IF (radius .LT. 0) EXIT
    ... area calculation
    PRINT*, "Area of circle with radius ",&
            radius, " is ", area
    PRINT*, "Volume of sphere with radius ",&
            radius, " is ", volume
  END DO
  END PROGRAM Area

In this way when a negative radius is supplied the program will terminate.

Hint 2: use the value 3.1459 for tex2html_wrap_inline3160 .

Go back to Notes gif




next up previous contents
Next: Solution Up: Introduction to Fortran 90 Previous: Solution

©University of Liverpool, 1997
Thu May 29 10:11:26 BST 1997
Not for commercial use.