Hello Guys,
I am new starter with Fortran, I am trying to use iteration to find the value of i in the following equation:
Tan(i)/Cos(i)=Y
My program is as below:
program hello
Implicit none
parameter(PI=3.14159265359)
Integer::i
real::X,pi,y,s,V,D
read(*,*)y
do i=1,90,1
X=tan((i*pi/180))/cos((i*pi/180))
S=x-Y
if (s<=0.001)then
write(*,*)i,s
end if
end do
end
the program runs well and finds the value of i ( between 0 and 90)which satisfies the logical condition
Example:
for Y=0.1 the output is like below:
1 -8.254228E-02
2 -6.505795E-02
3 -4.752030E-02
4 -2.990244E-02
5 -1.217714E-02
6 5.683184E-03
My question is how can I make the program takes the last value (5.683184E-03 in the example) and use it in a following part of the program?
I hope I made my question clear!
Could anyone help me with this?
Thanks in advanced
I am new starter with Fortran, I am trying to use iteration to find the value of i in the following equation:
Tan(i)/Cos(i)=Y
My program is as below:
program hello
Implicit none
parameter(PI=3.14159265359)
Integer::i
real::X,pi,y,s,V,D
read(*,*)y
do i=1,90,1
X=tan((i*pi/180))/cos((i*pi/180))
S=x-Y
if (s<=0.001)then
write(*,*)i,s
end if
end do
end
the program runs well and finds the value of i ( between 0 and 90)which satisfies the logical condition
Example:
for Y=0.1 the output is like below:
1 -8.254228E-02
2 -6.505795E-02
3 -4.752030E-02
4 -2.990244E-02
5 -1.217714E-02
6 5.683184E-03
My question is how can I make the program takes the last value (5.683184E-03 in the example) and use it in a following part of the program?
I hope I made my question clear!
Could anyone help me with this?
Thanks in advanced