у меня есть следующий упрощенный алгоритм для вычисления корней квадратного уравнения
#include <iostream>
#include <math.h>
using namespace std;
int main(){
float x,x1;
x=0;x1=0;
int a=1;
int b;
int c;
cout<<"enter the second term:"<<endl;
cin>>b;
cout<<"enter the third term:";
cin>>c;
float d=b^2-4*a*c;
if (d<0){
cout<<"the equation has not real solution :"<<endl;
}
else if (d==0) { x=(-b/2); x1=x;}
else
{
x=(-b+sqrt(d))/2;x1=(-b-sqrt(d))/2;
}
cout<<"roots are :"<<x<< " "<<x1<< " "<<endl;
return 0;
}
но это дает мне предупреждение
arning C4244: '=' : conversion from 'int' to 'float', possible loss of data
и когда я ввожу -6 и 9, это дает, что корни равны 6 и нулю, что, конечно, не соответствует действительности, пожалуйста, помогите мне