Hi i am just starting out with c++ and i have a problem, i tried to make a program that solves second degree equtations of this form: ax^2+bx+c=0.
and here is the code:
This program solve the equation: ax^2 + bx + c=0
Enter coefficient a:1
Enter coefficient b:2
Enter contstant c:1
delta = 0
There is one solution: x = -1
First solution: x1 = 1.91474e-307
Second solution: x2 = -1
i don't want the last 2 lines to appear.
and when delta > 0 the program shows this:
This program solve the equation: ax^2 + bx + c=0
Enter coefficient a:2
Enter coefficient b:5
Enter contstant c:2
delta = 9
There is one solution: x = nan
First solution: x1 = -2
Second solution: x2 = -0.5
i dont want "There is one solution: x = nan" to be shown.
while if delta<0 i have:
This program solve the equation: ax^2 + bx + c=0
Enter coefficient a:6
Enter coefficient b:2
Enter contstant c:5
delta = -116
There is one solution: x = nan
First solution: x1 = 1.91474e-307
Second solution: x2 = nan
There is no real solution, there is two complex solutions.