What is wrong with this?
Hello. I am a beginner in C++ language. I don't understand why the code for solving second power equations, runs, but outputs wrong solutions. Thanks in advance. #include <iostream> #include <math.h> using namespace std; int main() { int x1; int d; int a; int b; int c; int x2; int x; cin >>a >>b >>c; cout <<"a value " <<a <<endl <<"b value " <<b <<endl <<"c value " <<c <<endl ; int D = b * b - 4 * a * c ; // when it has a solution if (D > 0) { d= sqrt (D); x1= ( - b + d) / 2 * a ; x2 = ( - b - d) / 2* a ; cout <<"x1 = " <<x1 <<endl <<"x2 = " <<x2 ; } // when it has only one solution if (D=0){ x= -b / 2 * a ; cout <<" there is only one solution in wich x=" <<x ; } //when it doesn't have a solution if (D<0){ cout << "this equation has no solution"; } return 0; }