Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  program_3_alieh rostami.f
Language: FORTRAN
Code:
program nabejayi
implicit none
INTEGER::k
REAL::a,b,fa,fb,x,e,c,y
!F(x)=3*X-(2.718)**X
PRINT*
PRINT*,"   F(X) =3*X-(2.718)**X X = ? "
PRINT*
PRINT*,"   Baraye baze [a,b],  a & b ra vared konid : "
READ*,a,b
PRINT*,"   Nerkhe hamgarayi ra vared konid : "
READ*,c
x=0
k=0
do
k=k+1
y=x
fa=3*(a)-(2.718)**a
fb=3*(b)-(2.718)**b
x=(a*fb - b*fa)/(fb-fa)
e=ABS((x-y))/ABS(x)
if (e < c) then
exit
end if
if ((x*fa) > 0) then
a=x
else
if ((x*fa) < 0) then
b=x
else
exit
end if
end if
end do
PRINT*,"   Javab dar tekrar",k," barabar ast ba :    X =",x
PRINT*
end
Comments: