0

Hey guys I'm new to programing and I made a program to solve quadratic formula but it doesn't work with imaginary numbers when the number is negative I get something like this -1.#IND. What can I add or adjust in my code to help get the program to show imaginary 'complex numbers'. Thanks!

Edit: Also is there a way to do this without the #include <complex>\

```
#include <iostream>
#include <cmath>
using namespace std;
double a, b, c, rootvalue1, rootvalue2;
int main()
{
cout <<"This program will have you enter coefficients a,b, and c.\n" //Explains what the program will do.
"This will calculate two root values using the quadratic formula." << endl;
cout <<"Enter Coefficient a: ";
cin >> a;
if (a == 0) //If user enters 0 it will quit the program and give them error message.
{
cout << "0 is not a sufficient coefficient for this program.\n";
cout <<"Restart now and try again." << endl;
exit(0);
}
cout <<"Enter Coefficient b: ";
cin >> b;
cout <<"Enter Coefficient c: ";
cin >> c;
rootvalue1 = (-b + sqrt(b * b - 4 * a * c)) / (2 * a); // Quadratic formula
rootvalue2 = (-b - sqrt(b * b - 4 * a * c)) / (2 * a);
cout <<"The first Root Value = " << rootvalue1 << endl; //Roo Answer
cout <<"The second Root Value = " << rootvalue2 << endl;
return 0;
}
```

*Edited
by Sasquadge*