this is my code
#include
#include
using namespace std;
int main() {
int a, b, c, d;
float root1, root2;
cin >> a >> b >> c;
d = b * b - 4 * a * c;
if (d < 0)
cout<<“Imaginary”;
else if (d == 0){
cout<<“Real and Equal”<<endl<<-b / float(2 * a)<<endl;
}
else{
root1 = (-b + sqrt(d)) / (2 * a);
root2 = (-b - sqrt(d)) / (2 * a);
cout<<“Real and Distinct”<<endl<<root2<<" "<<root1<<endl;
}
return 0;
}
I can't figure out the error in revising quadratic equation problem
#include
#include<math.h>
using namespace std;
int main() {
int a, b, c, d;
float root1, root2;
cin >> a >> b >> c;
d =( b * b - 4 * a * c);
if (d < 0)
cout<<“Imaginary”;
else if (d == 0){
cout<<“Real and Equal”<<endl<<-b / float(2 * a)<<" “<<-b / float(2 * a)<<endl;
}
else{
root1 = (-b + sqrt(d)) / (2 * a);
root2 = (-b - sqrt(d)) / (2 * a);
cout<<“Real and Distinct”<<endl<<root2<<” "<<root1<<endl;
}
return 0;
}
your logic is correct i have done some modification see it