Quadratics help

Hi, i've just started my second year of my physics degree and i have to do a computing module but my tutor is useless so could someone check where ive gone wrong with this basic quadratic equation program please it doesn't actually calculate the values for x1 and x2

thanks
________________________________________________________________________________


#include "stdafx.h"
#include <iostream>
#include <cmath>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
//Declare variables
double a = 0.0;
double b = 0.0;
double c = 0.0;
double x1 = 0.0;
double x2 = 0.0;

cout << "Enter the value for a";
cin >> a;
cout << "Enter the value for b";
cin >> b;
cout << "Enter the value for c";
cin >> c;

cout << "x1 = (-b + sqrt(b * b - 4 * a * c)) / (2 *a)" &&
cout << "x2 = (-b - sqrt(b * b - 4 * a * c)) / (2 * a)";

system("pause");
return 0;
}

________________________________________________________________________________
you need to make this change to move from advisory text to formula:

1
2
3
4
x1 = (-b + sqrt(b * b - 4 * a * c)) / (2 *a);
x2 = (-b - sqrt(b * b - 4 * a * c)) / (2 * a);
cout << x1<<endl;
cout <<x2<<endl; 

also you need to introduce a control which will abandon the search for the roots if 4*a*c >b^2
Topic archived. No new replies allowed.