IF THEN ELSE STATEMENT PROGRAMS
13: Write
a program to calculate the sum of the following series (2/3+4/5+6/7+.…+2N/2N+1
)
real sum,i,n
write(*,*)'Enter Value of N = '
read(*,*)n
i=1.0
sum=0.0
30 sum=sum+(2*i)/(2*i+1)
i=i+1
if(i.LE.N)GOTO 30
write(*,*)'Sum of Series = ',sum
stop
end
14: Write
a program to calculate the sum of the following series (1-3/2^2
+5/3^2
..…. ±(2N-1/N^2
))
real sum,i,k,n
write(*,*)'Enter Value of N'
read(*,*)n
i=1.0
k=1.0
sum=0.0
30 sum=sum+k*(2*i-1)/(i**2)
i=i+1
k=-k
if(i.LE.N)GOTO 30
write(*,*)'Sum of Series = ',sum
stop
end
0 Comments