A function in fortran.
!Illustrate use of function sub program
!function sub program is given below
program func_use
implicit none
interface
function S(x)
real::S
real,intent(in)::x
end function
end interface
real::x,g
print*,"Please entre the value of x"
read*,x
print*,"x=",x
g=S(x+2)+S(x**2)
print*,"g=",g
end program func_use
function S(x)
implicit none
real::S
real,intent(in)::x
S=x**2+x+4
end function
!function sub program is given below
program func_use
implicit none
interface
function S(x)
real::S
real,intent(in)::x
end function
end interface
real::x,g
print*,"Please entre the value of x"
read*,x
print*,"x=",x
g=S(x+2)+S(x**2)
print*,"g=",g
end program func_use
function S(x)
implicit none
real::S
real,intent(in)::x
S=x**2+x+4
end function