Was wondering why this bit won't compile. I get the errors in the line r1 = ((-B) + sqrt(B^2 - 4*A*C)/(2*A); .
before, when types A, B, C, r1 and r2 were ints, it would compile but all answers would be -2147... then when I tried changing the types to float and then double is when it stopped even compiling.
1 2 3 4 5 6 7 8 9 10 11
cout << "This tool solves quadratics ONLY in the form of: \n\tAx^2 + Bx + C" << endl;
cout << "Please enter the 'A' in your problem: " << endl;
cin >> A;
cout << "Please enter the 'B': " << endl;
cin >> B;
cout << "Please enter the 'C': " << endl;
cin >> C;
r1 = ((-B) + sqrt(B^2 - 4*A*C)/(2*A);
r2 = ((-B) - sqrt(B^2 - 4*A*C) / (2*A);
cout << "The first result is " << r1 << endl;
I know in quadratic formulas, there is a possibility of "imaginary numbers". If I were you, I would check to see if (B * B) - 4 * A * C is >= 0, and if it isn't, then make it positive after the calculation then add an "i" at the end indicating imaginary number.