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.  
  7. read(*, *) a, b, c
  8. root1 = (-b + sqrt(d)) / (2.0*a)
  9. root2 = (-b - sqrt(d)) / (2.0*a)
  10. print *, 'x1 = ', root1
  11. print *, 'x2 = ', root2
  12. end program quadratic_equation
  13.  
Success #stdin #stdout 0s 5304KB
stdin
1, -2, -3
stdout
 x1 =    1.00000000    
 x2 =    1.00000000