How to declare sqrt ? As code is not running and telling error in sqrt
#include <iostream> using namespace std; int main() { int a , b , c , discriminant , x1 , x2 , real_part , imaginary_part ; cout << "Enter coefficients of a , b , c " << endl ; cin >> a >> b >> c ; discriminant = (b*b) - (4*a*c) ; if (discriminant>0) { cout << "Roots are real and different" ; x1 = (-b + sqrt(discriminant)) / (2*a) ; x2 = (-b - sqrt(discriminant )) /(2*a) ; cout << "x1 = " << x1 << "x2 = " << x2 ; } else if (discriminant == 0) { cout << "Roots are equal\n" ; x1 = (-b/2*a) ; cout << "x1=x2 = " << x1 ; } else { real_part = (-b/2*a) ; imaginary_part = sqrt (-discriminant) /2*a ; cout << "x1 is " << real_part <<"+" << imaginary_part << "i" ; } return 0; }