program sinx_using_subroutine
real*16::sum,x,a
integer::i,n
print*,'Enter the angle:-'
read*,x
print*,'Enter the no of countable steps:-'
read*,n
!converting the angle from degree to radian
x=x*3.14159/180
sum=0
j=0
do i=1,n+1,2
j=j+1
call f(i,a)
sum=sum+((-1)**(j+1))*x**i/a
enddo
print*,'Sin',x*180/3.14159,'=',sum
end program
!subroutine of factorial
subroutine f(n,prod)
integer::n
real*16::prod
prod=1
do i=1,n
prod=prod*i
enddo
return
end
real*16::sum,x,a
integer::i,n
print*,'Enter the angle:-'
read*,x
print*,'Enter the no of countable steps:-'
read*,n
!converting the angle from degree to radian
x=x*3.14159/180
sum=0
j=0
do i=1,n+1,2
j=j+1
call f(i,a)
sum=sum+((-1)**(j+1))*x**i/a
enddo
print*,'Sin',x*180/3.14159,'=',sum
end program
!subroutine of factorial
subroutine f(n,prod)
integer::n
real*16::prod
prod=1
do i=1,n
prod=prod*i
enddo
return
end
Comments
Post a Comment