Here is a simple Learner practice piece of Code, which supposses to comply and give solutions to a Quadrant Equity problem (requires to give it values of a, b and c for a Quadrant function). Please any tips and Tricks highly welcome, and suggestions of Improving the code. Thanks.
#include <iostream>
#include <math.h>
using namespace std;
void main(){
double a, b, c;
cin >> a >> b >> c;
if(a == 0){
if(b == 0){
if(c == 0){
cout<<"All real numbers are solutions!"; //always zero
return 0;
}
cout<<"No solutions!"; //no soultion Found
return 0;
}
cout<<"Solution x0 is "<< -c / b; // Line equity
return 0;
}
double delta = b*b - 4*a*c; // calculate the derivative for Quadrant
if(delta<0){
cout <<"No real solutions!"; //none Found
}
else if(delta==0){
cout <<"Solution x0 is "<<-b / (2*a); //Double solution
}
else {
cout <<"Solution x1 is "<<( -b - sqrt( delta ) ) / (2*a) << endl;
cout <<"Solution x2 is "<<( -b + sqrt( delta ) ) / (2*a);
}
return 0;
}
else if(delta==0){
Shouldn't this rather compare againststd::numeric_limits<double>::epsilon
? \$\endgroup\$