- #1
jelanier
- 67
- 1
I have a simple iteration program that does something I can't explain. It has to do with the use of if then statements. I can't see why this change would change the outcome. Here are the 2 examples:
This works:
if (guess.eq.target) then
lp=3
write (*,*) vv,lp,guess,target
go to 20 !go to end, guess = target
end if
if (guess.gt.target) then
guess = guess / vv !decrease guess
lp=1
else if (guess.lt.target) then
guess = guess * vv !increase guess
lp=2
end if
******************************************************
This doesn't work:
if (guess.eq.target) then
lp=3
write (*,*) vv,lp,guess,target
go to 20 !go to end, guess = target,
end if
if (guess.gt.target) then
guess = guess / vv !decrease guess
lp=1
end if
if (guess.lt.target) then
guess = guess * vv !increase guess
lp=2
end if
*************************************************
Any ideas?
Here are the 2 programs:attached
Thanks,
Jim
This works:
if (guess.eq.target) then
lp=3
write (*,*) vv,lp,guess,target
go to 20 !go to end, guess = target
end if
if (guess.gt.target) then
guess = guess / vv !decrease guess
lp=1
else if (guess.lt.target) then
guess = guess * vv !increase guess
lp=2
end if
******************************************************
This doesn't work:
if (guess.eq.target) then
lp=3
write (*,*) vv,lp,guess,target
go to 20 !go to end, guess = target,
end if
if (guess.gt.target) then
guess = guess / vv !decrease guess
lp=1
end if
if (guess.lt.target) then
guess = guess * vv !increase guess
lp=2
end if
*************************************************
Any ideas?
Here are the 2 programs:attached
Thanks,
Jim