C Program to find sine of a given angle
write(*,*)'Enter the angle in degree:'
read(*,*)y
sum=0.0
term=1.0
i=1
s=1.0
x=(acos(-1.0)*y)/180.0
dowhile (abs(term).ge.1.0E-6)
term=(x**i/fact(i))*s
sum=sum+term
i=i+2
s=-s
end do
write(*,10)y,sum
10 format(2x,'The value of sin',f16.2,' is',f16.4)
end
C Program sub function
function fact(i)
fact=1
do j=1,i
fact=fact*j
end do
return
end
write(*,*)'Enter the angle in degree:'
read(*,*)y
sum=0.0
term=1.0
i=1
s=1.0
x=(acos(-1.0)*y)/180.0
dowhile (abs(term).ge.1.0E-6)
term=(x**i/fact(i))*s
sum=sum+term
i=i+2
s=-s
end do
write(*,10)y,sum
10 format(2x,'The value of sin',f16.2,' is',f16.4)
end
C Program sub function
function fact(i)
fact=1
do j=1,i
fact=fact*j
end do
return
end
Comments
Post a Comment