I'm trying to make a program to calculate the output of a 2nd degree equation, using functions, but Dev C++ keeps giving me the output "[Error] Id returned 1 exit status". I'm a newbie in C++, sorry in advance if I made some stupid errors.
#include <iostream>
#include <cmath>
using namespace std;
float equation1 (float, float, float);
float equation2 (float, float, float);
main()
{
float a, b, c, Res1, Res2;
cout << "Insert the parameters of the equation.\n";
cin >> a >> b >> c;
if (a == 0)
{
Res1 = b / c;
cout << "It's a 1st degree eq. and the result is " << Res1 << endl;
}
else
{
Res1 = equation1 (a, b, c);
Res2 = equation2 (a, b, c);
cout << "The results of the eq. are " << Res1 << " and " << Res2 << endl;
}
system ("pause");
return 0;
}
float equation1 (double a, double b, double c)
{
float D, Res1;
D = (b * b) - 4 * a * c;
Res1 = (- b + sqrt(D)) / (2 * a);
return Res1;
}
float equation2 (double a, double b, double c)
{
float D, Res2;
D = (b * b) - 4 * a * c;
Res2 = (- b - sqrt(D)) / (2 * a);
return Res2;
}