Program c02ajfe

!     C02AJF Example Program Text

!     Mark 26.1 Release. NAG Copyright 2016.

!     .. Use Statements ..
      Use nag_library, Only: c02ajf, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: a, b, c
      Integer                          :: ifail
!     .. Local Arrays ..
      Real (Kind=nag_wp)               :: zlg(2), zsm(2)
!     .. Intrinsic Procedures ..
      Intrinsic                        :: abs
!     .. Executable Statements ..
      Write (nout,*) 'C02AJF Example Program Results'

!     Skip heading in data file
      Read (nin,*)

      Read (nin,*) a, b, c

      ifail = -1
      Call c02ajf(a,b,c,zsm,zlg,ifail)

      If (ifail==0) Then
        Write (nout,*)
        Write (nout,*) 'Roots of quadratic equation'
        Write (nout,*)

        If (zsm(2)==0.0E0_nag_wp) Then

!         2 real roots.

          Write (nout,99999) 'z = ', zsm(1)
          Write (nout,99999) 'z = ', zlg(1)
        Else

!         2 complex roots.

          Write (nout,99998) 'z = ', zsm(1), ' +/- ', abs(zsm(2)), '*i'
        End If

      End If

99999 Format (1X,A,1P,E12.4)
99998 Format (1X,A,1P,E12.4,A,E12.4,A)
    End Program c02ajfe