IF THEN ELSE STATEMENT PROGRAMS
11: Write
a program to calculate the sum of the following series (1+1/2^2
+1/3^2
.….+1/100^2 )
real i,sum
sum=0
i=1
30 sum=sum+1/i**2
i=i+1
if(i.LE.100)GOTO
30
write(*,*)'Sum
of series = ',sum
stop
end
12: Write
a program to calculate the sum of the following series (1-1/2^2
+1/3^2
-…...-1/100^2 )
real sum,i,j
sum=0.0
j=1.0
i=1.0
30 sum=sum+j/i**2
i=i+1
j=-j
if(i.LE.100)GOTO
30
write(*,*)'Sum of series = ',sum
stop
0 Comments