answersLogoWhite

0

implicit double precision(a-h,o-z)

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

User Avatar

Wiki User

12y ago

Still curious? Ask our experts.

Chat with our AI personalities

RossRoss
Every question is just a happy little opportunity.
Chat with Ross
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
CoachCoach
Success isn't just about winning—it's about vision, patience, and playing the long game.
Chat with Coach

Add your answer:

Earn +20 pts
Q: Write a fortran code to calculate the root of quadratic equation?
Write your answer...
Submit
Still have questions?
magnify glass
imp