write(*,*) “please provide the a,b,c coeff”
read(*,*) A,B,C
D=B*B-4*A*C
if(D.GT.0) then
root1=(-B/(2*A))+(SQRT(D))/(2*A)
root2=(-B/(2*A))-(SQRT(D))/(2*A)
write(*,*) root1,root2
elseif(D.EQ.0) then
root1=(-B/(2*A))
root2=root1
write(*,*) root1,root2
else
root1=(-B/(2*A))+(SQRT(-D))/(2*A)
root2=(-B/(2*A))-(SQRT(-D))/(2*A)
a=(root1+root2)/2
b=(root1-root2)/2
write(*,*) ‘realpartroot=’,a, ‘complexpartroot=’,b
endif
stop
END
read(*,*) A,B,C
D=B*B-4*A*C
if(D.GT.0) then
root1=(-B/(2*A))+(SQRT(D))/(2*A)
root2=(-B/(2*A))-(SQRT(D))/(2*A)
write(*,*) root1,root2
elseif(D.EQ.0) then
root1=(-B/(2*A))
root2=root1
write(*,*) root1,root2
else
root1=(-B/(2*A))+(SQRT(-D))/(2*A)
root2=(-B/(2*A))-(SQRT(-D))/(2*A)
a=(root1+root2)/2
b=(root1-root2)/2
write(*,*) ‘realpartroot=’,a, ‘complexpartroot=’,b
endif
stop
END
thanks brother
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteWhat is the meaning of root1 + root2/2
ReplyDeleteUsing Fortran obtain the root of quadratic question ax^2+6x+c=0
ReplyDeleteWell-done sir
ReplyDeletecan anyone give me the link to download the exe and batch file for fortran77. I want to use the same for coding!
ReplyDeleteFortran program to solve quadratic equation
ReplyDelete