Homework Statement. [/B]Hello all !! I am currently trying to make my fortran95 code run in vain.I would really appreciate it if someone could lend my a hand since I am a starter in programming.So the problem goes like that:Create a program capable of calculating the following function: f(x)=1/x when x<3 , x+2(x)^2 when 3≤x≤8 and finally sqrt(x-10) when x>8
The problem is that my code will pop up a window 'Error' and it is indicated that the problem is with the square root .Thanks in advance!
The Attempt at a Solution.[/B]
Mod note: Added code tags.
program function implicit none integer::st=0 real::x,y1,y2,y3 print*,'Welcome to the function y=1/x , x<3 & & 2.*x**2.+x 3<=x<=8 and sqrt(x-10),x>8 ' print*,'input to x' read (*,*,iostat=st) x pr:if (st /=0) then print*,'possible error' stop else pr ex:if (abs(x-3)<1e-6 .or. abs(x)<1e-6) then y1=1./x print*,y1 else ex in: if (abs(x-3)>=1e-6 .and. abs(x-8)<=1e-6) then y2=(2*x)**2+x print*,y2 else in out:if (abs(x-8)>1e-6 .and. abs(x-10)<1e-6) then print*,'impossible' stop else out br:if (abs(x-10)>=1e-6) then y3=sqrt(x-10) print*,y3 end if br end if out end if in end if ex end if pr end program
Last edited by a moderator: