c This program gives the value of cos x to 10 decimal places.
c It works if x is not too large, say between -10 and 10.
c For larger x round-off error take effect.
double precision x, term, sum
print *, "Enter a real number x :"
read *, x
sum = 0D0
term = 1D0
I = 1
do while (abs(term) .ge. 1.D-12)
sum = sum + term
term = - term * x * x / ((2*I-1) * (2*I))
I = I + 1
write (*,5) "The value of cos x to 10 decimal places is : ", sum
5 format (a,f13.10)
print *, "Bye"