C Program to find the sum of the series 1 + 1/3 + 1/5 + ... upto n terms
write(*,*)'Enter the no. of terms:'
read(*,*)n
sum=0.0
i=1
do j=1,n
sum=sum+1.0/i
i=i+2
end do
write(*,10)sum
10 format(2x,'The sum of the series is',f16.4)
end
write(*,*)'Enter the no. of terms:'
read(*,*)n
sum=0.0
i=1
do j=1,n
sum=sum+1.0/i
i=i+2
end do
write(*,10)sum
10 format(2x,'The sum of the series is',f16.4)
end
Comments
Post a Comment