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

ProfessorProfessor
I will give you the most educated answer.
Chat with Professor
JordanJordan
Looking for a career mentor? I've seen my fair share of shake-ups.
Chat with Jordan
BeauBeau
You're doing better than you think!
Chat with Beau

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