/ Published in: C++
A simple program solving a biquadratic equation.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include <iostream> #include <math.h> using namespace std; void main() { float a, b, c, dis, x1, x2; cout << "Enter a: "; cin >> a; cout << "Enter b: "; cin >> b; cout << "Enter c: "; cin >> c; dis = b*b - 4*a*c; if ( dis>= 0 ) { x1 = (b - sqrt (dis) ) / 2*a; x2 = (b + sqrt (dis) ) / 2*a; cout << "The result is" << x1 << " and " << x2 << endl; } else { cout << "Dis is less than 0\n"; } }