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,

equation1228

Volume of a sphere,

equation1231

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.

  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

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

Hint 2: tex2html_wrap_inline2760 . tex2html_wrap_inline2762 in Fortran 90 is ATAN.




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

Adam Marshall ©University of Liverpool, 1996
Fri Dec 6 14:10:26 GMT 1996