Skip to content

Instantly share code, notes, and snippets.

@MohammedBadr20s
Created February 13, 2015 06:21
Show Gist options
  • Save MohammedBadr20s/9b571f52576c75791de1 to your computer and use it in GitHub Desktop.
Save MohammedBadr20s/9b571f52576c75791de1 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
float A , B , C ;
double delt , root , R1 , R2;
cin >> A >> B >> C;
delt = pow(B,2) - 4*A*C;
if (root = 0 || delt < 0 )
{
cout << "Impossivel calcular" << endl;
}
else
{
R1 = -B + sqrt(delt)/2*A;
R2 = -B - sqrt(delt)/2*A;
cout << fixed << setprecision(5) << "R1 = " << R1 << "\nR2 = " << R2 << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment