Exercise 5: Two roots of the quadratic equation is calculated by using the formula:
Where a, b and c are real values. The term is called discriminant. Write a program in C++ for the solutions of the quadratic equation for which . The program will calculate the discriminant first. Depending on the value of the discriminant it will do the following:
if the discriminant , it will display the message as follows
-----------------------------------------------------
Discriminant (b^2 – 4*a*c) =
Quadratic equation has no real solutions
-----------------------------------------------------
if the discriminant , it will display the solutions as follows
---------------------------------------------------------------
Discriminant (b^2 – 4ac) =
Quadratic equation has two coincided real solutions
X1=X2= (-b/2a) =
---------------------------------------------------------------
If the discriminant , it will display two solutions as follows:
--------------------------------------------------
Discriminant (b^2 – 4ac) =
The two real solutions are:
X1= (-b+sqrt(b^2 – 4ac)/2a =
X2= (-b-sqrt(b^2 – 4ac)/2a =
--------------------------------------------------
The program has to run at least 3 times to show the three situations.
Hi
Can anyone help with this above problem?.
Compiler used is Borlands C++.
I am having problems with the results it dislays if you run the program and look at the answers they dont match what they should be for example if the discriminant is less than zero it should print a value for x1 and x2 but it does not.