1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Function main () Returns 0 on success
Open "coeffs.txt" for reading using a defined ifstream object named fin
a ← ReadCoeff ( fin )
b ← ReadCoeff ( fin )
c ← ReadCoeff ( fin )
Close fin
root1 ← CalcRoot1 ( a, b, c )
root2 ← CalcRoot1 ( a, b, c )
Output ( a, b, c, root1, root2 )
Return 0
End Function main
Function ReadCoeff ( fin is ifstream& ) Returns the coefficient as double
Read from fin into defined double variable coeff
Return coeff
End Function ReadCoeff
Function Discriminant ( a is double, b is double, c is double ) Returns the discriminant as double
Return b
2 ‒ 4ac
End Function
Function CalcRoot1 ( a is double, b is double, c is double ) Returns root1 as double
Return ‒b + sqrt ( Discriminant ( a, b, c ))
End Function
Function CalcRoot2 ( a is double, b is double, c is double ) Returns root2 as double
Return ‒b  sqrt ( Discriminant ( a, b, c ))
End Function
Function Output( a is double, b is double, c is double, root1 is double, root2 is double ) Returns nothing
Open "roots".txt for writing using a defined ofstream object named fout
Configure fout so real numbers are displayed with five digits after the decimal point
Write to fout "The equation " a " x^2 + " b " x + " c " = 0 has roots " root1 " and " root2
Close fout
End Function
