I am ultimately looking to find if I should be doing something differently |
The biggest problem is indeed a call to main() at line 74. This is undefined behavior in C++ (main is a special function; it is called by the OS and never by the programmer)
Other problems compilers point out are the unknown escape sequences at line 13: backslash in a string literal should be followed by another backslash, like so:
Made by \\CodeKwik\\
As for layout, your comment at line 21 says "User Input Variables", but line 22 constructs a lot more than just a, b, and c. There is no point of having, for example,
discrim
created at line 22 and unused all the way until line 35 where you finally have a value to put into it. I would trim line 22 to just
double a,b,c;
and make line 35
double discrim = (pow(b, 2.0) - (4 * a * c));
(the coresponding guideline in the C++ Coding Standards (the book) is item 18 "Declare variables as locally as possible."
The output could be made a bit more compact with, for example, line 65-67 written out as
1 2 3 4
|
std::cout << "The discriminant is " << discrim << " and this means the\n"
<< "equation has TWO REAL ROOTS" << "\n\n"
<< "X Value #1 =" << value1 << '\n'
<< "X Value #2 =" << value2 << '\n';
|
but it's really just personal preference - it doesn't change the way the program executes (well, except for the endl vs \n: endl is not needed anywhere in this program, and using it instead of \n makes it run a bit slower, but of course there's no noticable difference in the user experience - you can use whatever you want as long as you keep that in mind)
Another thing to keep in mind: you've compared a double with a zero using operator == at line 52. The type double has limited precision, and in future you may often find yourself in situations where the result of a formula is supposed to be exactly zero, but it is off by some very small amount, in which case == would return false. It's not a big deal for this program either.