Best Answer

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

Q: Write a fortran code to calculate the root of quadratic equation?

Write your answer...

Submit

Still have questions?

Continue Learning about Math & Arithmetic

computer scince

ax2 + bx + c

Write the quadratic equation in the form ax2 + bx + c = 0 The roots are equal if and only if b2 - 4ac = 0. The expression, b2-4ac is called the [quadratic] discriminant.

First, write the equation in standard form, i.e., put zero on the right. Then, depending on the case, you may have the following options:Factor the polynomialComplete the squareUse the quadratic formula

You do not need to write anything to calculate things mentally.

Related questions

dejene

Write an algorithm to find the root of quadratic equation

readuse the answer

2000X=Y2KoverZzz?

Solve simple intress usin fortran

Write the quadratic equation in the form ax2 + bx + c = 0 then the roots (solutions) of the equation are: [-b ± √(b2 - 4*a*c)]/(2*a)

ax2 + bx + c

computer scince

Write the quadratic equation in the form ax2 + bx + c = 0 The roots are equal if and only if b2 - 4ac = 0. The expression, b2-4ac is called the [quadratic] discriminant.

Yes. The FORTRAN write command output's data to a file.

First, write the equation in standard form, i.e., put zero on the right. Then, depending on the case, you may have the following options:Factor the polynomialComplete the squareUse the quadratic formula

The easiest way to write a generic algorithm is to simply use the quadratic formula. If it is a computer program, ask the user for the coefficients a, b, and c of the generic equation ax2 + bx + c = 0, then just replace them in the quadratic formula.