Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Program: raices.cc
- // Author: Yoan Pinzon
- // Date: Agosto 30, 2006
- #include <iostream>
- using namespace std;
- int main()
- {
- float a, b, c, d, x1, x2;
- cout << "Calculo de Raices para Ax^2 + Bx + C = 0" << endl;
- cout << "========================================" << endl;
- cout << "Entre el valor de A = "; cin >> a;
- cout << "Entre el valor de B = "; cin >> b;
- cout << "Entre el valor de C = "; cin >> c;
- d = ( b * b ) - ( 4 * a * c ); // discriminante
- x1 = -b + sqrt( d ); x1 /= 2 * a;
- x2 = -b - sqrt( d ); x2 /= 2 * a;
- cout << endl;
- cout << "Las raices de \""
- << a << "x^2 +" << ( b<0? "\b" : " " )
- << b << "x +" << ( c<0? "\b" : " " )
- << c << " = 0\" son:" << endl;
- cout << "X1 = " << x1 << endl;
- cout << "X2 = " << x2 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement