# Thread: Help with my program's logic?

1. ## Help with my program's logic?

Can anyone help me figure out what's wrong?I can't get the program to compile. I'm using QT and you can just ignore the QT statements (cin, cout).

Code:
```#include <QtCore/QCoreApplication>
#include <cmath>

using namespace std;

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

int quit;
int continueflag;
double aa, bb, cc;
double delta;
double x1, x2;

cout << "Solving quadratic equation" << endl;

while (!quit) {
cout << "What is the value of a? " << endl;
cin >> aa;
cout << "What is the value of b? " << endl;
cin >> bb;
cout << "What is the value of c? " << endl;
cin >> cc;

delta = bb * bb - 4.0 * aa * cc;
if ((delta >= 0) && (aa != 0.0)) {
x1 = (-bb + sqrt(delta)/(2.0 * aa);
x2 = (-bb - sqrt(delta)/(2.0 * aa);

cout << "Equation solution: x1 = " << x1 << " x2 = " << x2 << endl;

}
else
cout << "Equation is unsolvable." << endl;

cout << "[ENTER] to try again, [Q] to quit." << endl;
cin >> continueflag ;
if (continueflag == "Q") quit = 1;

return a.exec();
}
}```

2. That's C++. This is the C forum.

If you can't get it to compile, try compiling with your warning level turned up, then start at the top and fix the errors and warnings one by one until you don't have any left.

Your indentation is terrible. Also, your loop has return inside of it, so it's just going to end the program on the first pass through the loop.

Quzah.