0

Please tell me what do you think of the written code below, is it easy to follow? Does the code tells you what it does, or you have struggled realizing whats going on? and so on. Feel free to give suggestions, tips, advices and criticize! This will help me and help other members too...

Note:**i'm trying to know how other developers see my code & trying to see where i go wrong. Thus, the best way to evaluate myself is to post my source code and see what do you think about it.**

```
/**program description:
*
* this program is a simple quadratic equation
* solver. I tried to make the code talks about
* itself by giving good descriptive names and
* reducing unneeded comments
*
* simple exercise for you: validate user input
*
* Author: X-Shab
*
*/
#include <iostream>
#include <cmath>
using namespace std;
void quadraticFormula(double a, double b, double c, double *totalResults)
{
double numeratorSqrtResult = sqrt( (b*b) - (4*a*c) );
double denominatorResult = 2 * a;
double addNegativeTo_b = 0 - b;
if (denominatorResult == 0)
{
cout<<"Denominator is zero\n";
exit(0);
}
totalResults[0] = (addNegativeTo_b + numeratorSqrtResult)/denominatorResult;
totalResults[1] = (addNegativeTo_b - numeratorSqrtResult)/denominatorResult;
}
int main(void)
{
double a, b, c;
double x[2]; //store results of x
cout<<"Please Enter a, b, and c to get Results of x:\n";
cout<<"a: ";
cin>>a;
cout<<"b: ";
cin>>b;
cout<<"c: ";
cin>>c;
quadraticFormula(a, b ,c, &x[0]);
cout<<"\nYour Results are:"<<endl;
for(int i = 0; i < 2; i++)
{
cout<<"x = "<< x[i] <<endl;
}
system("pause");
return 0;
}
```