View Code of Problem 42

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;
int main( )
{
    float a;
    float b;
    float c;

    cin >> a;
    cin >> b;
    cin >> c;
    float d = b*b-4*a*c;
    float e =sqrt(d);

    if((b-4*a*c)>0)
    {
        cout << fixed <<setprecision(2) << "X1="<< (-b+e)/2*a <<endl ;
        cout << fixed <<setprecision(2) << "X2="<< (-b-e)/2*a <<endl ;
    }

    return 0;
}

Double click to view unformatted code.


Back to problem 42