program assignment_8
real::s,t,x
integer::i,n
open(1,file='1st.txt',status='unknown')
open(2,file='2nd.txt',status='unknown')
open(3,file='3rd.txt',status='unknown')
open(4,file='4th.txt',status='unknown')
do n=1,4
if(n==1)then
x=-0.1
1 x=x+0.1
s=x
write(n,*)x,s
if(x<3.4)goto 1
elseif(n==2)then
x=-0.1
2 x=x+0.1
t=x
s=x
do i=1,(n-1)
t=-t*x*x/(2*i*(2*i+1))
s=s+t
enddo
write(n,*)x,s
if(x<3.4)goto 2
elseif(n==3)then
x=-0.1
3 x=x+0.1
t=x
s=x
do i=1,(n-1)
t=-t*x*x/(2*i*(2*i+1))
s=s+t
enddo
write(n,*)x,s
if(x<3.4)goto 3
else
x=-0.1
4 x=x+0.1
s=sin(x)
write(n,*)x,s
if(x<3.4)goto 4
endif
enddo
end
real::s,t,x
integer::i,n
open(1,file='1st.txt',status='unknown')
open(2,file='2nd.txt',status='unknown')
open(3,file='3rd.txt',status='unknown')
open(4,file='4th.txt',status='unknown')
do n=1,4
if(n==1)then
x=-0.1
1 x=x+0.1
s=x
write(n,*)x,s
if(x<3.4)goto 1
elseif(n==2)then
x=-0.1
2 x=x+0.1
t=x
s=x
do i=1,(n-1)
t=-t*x*x/(2*i*(2*i+1))
s=s+t
enddo
write(n,*)x,s
if(x<3.4)goto 2
elseif(n==3)then
x=-0.1
3 x=x+0.1
t=x
s=x
do i=1,(n-1)
t=-t*x*x/(2*i*(2*i+1))
s=s+t
enddo
write(n,*)x,s
if(x<3.4)goto 3
else
x=-0.1
4 x=x+0.1
s=sin(x)
write(n,*)x,s
if(x<3.4)goto 4
endif
enddo
end
Comments
Post a Comment