Find Quadratic Eq: Root's

 

#include <iostream> using namespace std; int main() {

int a, b, c, pen, add, Rot1, Roott2;

cout << "ENTRE THE CONSTANT WITH x2 :";

cin >> a;

cout << "ENTRE THE CONSTANT WITH x :";

cin >> b;

cout << "ENTRE THE CONSTANT  :";

cin >> c;

pen = b*b - 4 * a*c; if (pen > 0)

add = 1;

else

add = 0;

switch (add) { case (1):

Rot1 = (-b + sqrt((b*b - 4 * a*c))) / (2 * a);

Roott2 = (-b - sqrt((b*b - 4 * a*c))) / (2 * a); break;

case(0):

Rot1 = (-b + sqrt((b*b - 4 * a*c))) / (2 * a);

Roott2 = (-b - sqrt((b*b - 4 * a*c))) / (2 * a); break;

default:


Rot1 = Roott2 = (-b) / 2 * a;

}

cout << endl << "Rot1 AND Roott2 ARE EQUAL TO RESPECTIVELY               " << Rot1 << " "

<< Roott2 << endl;

system("pause"); return 0;

}

Comments

Popular Posts