برنامج لحل معادله من الدرجه الثانيه ++c
include <iostream>
include <math>
using namespace std;
//this solves the equation a*x*x+b*x+c==0:
int main(){
float a,b,c;
cout<<"enter coefficients of quadratic equation:";
cin>>a >>b >>c ;
if(a==0{
cout<<"this is not quadratic a equation:a==0\n";
return 0;
}
cout<<"the equation is: <<a <<"x^2+"<<b <<"x+ "<<c <<"= 0\n"
double d, x1, x2;
d=b*b - 4*a*c;
if(d < 0){
cout<<"this equation has no real solutions:d<0\n";
return 0;
}
x1=(-b + sqrt(d)/(2*a);
x2=(-b - sqrt(d)/(2*a)
cout<<"the solutions are: "<< x1 <<" , "<<x2 <<endl;
return 0;
}