fork download
  1. program quadratic_equation
  2. implicit none
  3. real :: a, b, c
  4. real :: d, root1, root2
  5. d = b**2 - 4.0*a*c
  6. read(*, *) a, b, c
  7. root1 = (-b + sqrt(d)) / (2.0*a)
  8. root2 = (-b - sqrt(d)) / (2.0*a)
  9.  
  10. IF (d >= 0) THEN
  11. PRINT *, 'x1 = ', root1
  12. print *, 'x2 = ', root2
  13. ELSE
  14. PRINT *, 'there are no real roots'
  15. END IF
  16. end program quadratic_equation
Success #stdin #stdout 0s 5300KB
stdin
1
0
-4
stdout
 x1 =    0.00000000E+00
 x2 =   -0.00000000E+00