#include <cstdlib>
#include <iostream>
#include <limits>
#include <string>
#include "math.h"
usingnamespace std;
double a,b,c,Discriminant,thingy;
int main()
{
cout << "Please enter the first coefficient:";
cin >> a;
cout << "Please enter the second coefficient:";
cin >> b;
cout << "Please enter the third coefficient:";
cin >> c;
if (Discriminant < 0)
{
cout << "\nNo Solutions.\n";
return 0;
}
if (Discriminant == 0)
cout << "\nOne solution\n";
Discriminant = ((0-b) + sqrt(Discriminant))/2;
thingy = ((0-b) - sqrt(Discriminant))/2;
thingy = 1.16315432;
cout << "The answers are " << Discriminant << " and " << thingy;
system("PAUSE");
return 0;
}
I get this output:
Please enter the first coefficient:XXX
Please enter the second coefficient:XXX
Please enter the third coefficient:XXX
the answers are XXXX and X.#INDPress any key to continue...
Maybe I'm not paying enough attention but where is the value of Discriminant declared? Not the variable I can see it up there as a global but it looks like you're leaving Discriminant up to What ever left overs are in that memeory space.
Try initializing all your variables, then it'll be easier to see where you went wrong (theoretically at least). Also, Computergeek01 is correct, I can't see where you tell the computer what Discriminant is equal to. One more mistake I see is that you declare thingy to be a value that isn't one of the solutions.