MODULE
!Program name: MODULE
!Area
of the circle and exponent - module
example
module circle_exponent
Implicit none
real, parameter :: pi = 3.1415926536
real, parameter :: e= 2.7182818284
contains
subroutine consts()
print*, "Pi = ", pi
Print*, 'e= ', e
end subroutine consts
function areaCircle(r) result(a)
implicit none
real::r
real::a
!dummy argument
a = pi * r**2
end function areaCircle
function exponent(x) result(epx)
implicit none
real::x
real::epx !dummy argument
epx = e**x
end function exponent
end module circle_exponent
!main program
use circle_exponent
Real :: r
Real :: x
call consts()
Print *, 'Input the radius of the circle: '
read *, r
print*, 'Area of a circle with radius', r,
'= ', areaCircle(r)
Print *, 'Input the exponent of the base e:
'
read *, x
print*, 'The base e power to', x, '= ',
exponent(x)
Print *, 'Good bye'
stop
Comentários
Postar um comentário