rendered paste bodyProgram Roots;
uses CRT;
Var A, B, C, Root1, Root2, OnlyRoot: Real;
Begin
ClrScr;
Writeln('To find the roots of the equation:');
Writeln;
Writeln(' A(x^2) + Bx + C = 0');
Writeln;
Writeln('');
Write('Enter Coefficient A: ');
Readln(A);
Write('Enter Coefficient B: ');
Readln(B);
Write('Enter Coefficient C: ');
Readln(C);
Writeln;
If (A = 0) Then
Begin
Writeln('*** Equation Not Quadratic - Cannot Solve ***');
End
Else
If ((sqr(B) - (4 * A * C)) = 0) Then
Begin
OnlyRoot:= (- B) / (2 * A);
Writeln('Root = ', OnlyRoot:1:3, ' ONE ROOT ONLY');
End
Else
If ((sqr(B) - (4 * A * C)) < 0) Then
Begin
Writeln('*** Equation has Imaginary Roots - Cannot Solve ***');
End
Else
Begin
Root1 := (- B + (Sqrt(Sqr(B) - (4 * A * C)))) / (2 * A);
Root2 := (- B - (Sqrt(Sqr(B) - (4 * A * C)))) / (2 * A);
Writeln('Root 1 = ', Root1:1:3, ' Root 2 = ', Root2:1:3);
End;
Readln;
End.