rendered paste body
cout << "John Harrison, Assignment 2\n\n";
cout << "Input values for the co-efficients a,b,c in 'ax^2 + bx + c = 0'.\n";
double a, b, c, d;
cin >> a >> b >> c ;
cout << "Equation is " << a << "x^2 + " << b << "x + " << c << " = 0." << endl;
d=(b*b-4*a*c);
if(d < 0)
cout << "The roots are complex" << endl;
else if(d > 0)
cout << "There are two real roots : " << ( (-b+sqrt(d))/(2*a)) << " and " <<((-b-sqrt(d))/(2*a)) << endl;
else
cout << "There is one real root : " << (-b/(2*a)) << endl;
cin.get();
cin.get();