Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Please

Status
Not open for further replies.

Bahjat77

Technical User
Jun 21, 2010
1
GB
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top