FUNCTION

 !Name of the program: FUNCTION

   Real :: a, r

   character (len=1) :: answer

   Print *, 'Input the radius of the circle: '

   Read *, r

! Variable function:

   a = circle_area(r) 

 

   Print *, 'The area of a circle with radius ', r, ' is: '

   Print *, a

10   Print *, 'Do you want to calculate another area of a circle (Y/N)?'

   Read *, answer

   If (answer == 'Y') then

        Print *, 'Input the radius of the circle: '

        Read *, r

        a = circle_area(r)

        Print *, 'The area of a circle with radius ', r, ' is: '

        Print *, a

        Go to 10

      else

      print *, 'Ok. Goodbye.'

   end if

Stop

End

 

! this function computes the area of a circle with radius r

Function circle_area (r)

implicit none

   real :: circle_area

   ! local variables

   real :: r

   real :: pi

 

   pi = 4 * atan (1.0)

   area_of_circle = pi * r**2

end function circle_area

Comentários

Postagens mais visitadas deste blog

HYDROGEN-RADIAL

HYDROGEN-POTENTIAL

ONE_PART_QHO