fork download
  1. program quadratic_equation
  2. implicit none
  3. real :: a, b, c, discriminant, root1, root2
  4. a = 1.0
  5. b = 0
  6. c = 4.0
  7. discriminant = b**2 - 4.0*a*c
  8.  
  9. if (discriminant > 0.0) then
  10.  
  11. root1 = (-b + sqrt(discriminant)) / (2.0 * a)
  12. root2 = (-b - sqrt(discriminant)) / (2.0 * a)
  13. print *, "Root 1 =", root1
  14. print *, "Root 2 =", root2
  15. else if (discriminant == 0.0) then
  16. root1 = -b / (2.0 * a)
  17. print *, "Root =", root1
  18. else
  19. print *, "There are no real roots."
  20. end if
  21.  
  22. end program quadratic_equation
Success #stdin #stdout 0s 5276KB
stdin
Standard input is empty
stdout
 There are no real roots.