Structure of the Problem Requirements
A quadratic equation has the form ax4 + bx3 + cx2 + dx + e = 0. A general quartic equation (also called a biquadratic equation) is a fourth-order polynomial equation of the form.Source Code
#include <iostream>
#include <cmath>
#include <windows.h>
using namespace std;
int main() {
float a = 0.0 ;
float b = 0.0 ;
float c = 0.0 ;
float x1 = 0.0 ;
float x2 = 0.0 ;
float dtrmnt = 0.0 ;
float real = 0.0 ;
float imgpart = 0.0 ;
system("color 4a");
cout<<"\n\n\t********** Quadratic Equation *************\n\n\n";
cout << "Enter Coefficients A : ";
cin >> a ;
cout << "\n Enter Coefficients B : ";
cin >> b ;
cout << "\n Enter Coefficients C : ";
cin >> c ;
dtrmnt = b*b - 4*a*c;
if (dtrmnt > 0) {
x1 = (-b + sqrt(dtrmnt)) / (2*a);
x2 = (-b - sqrt(dtrmnt)) / (2*a);
cout<<endl<<endl;
cout << "x1 = " << x1 << endl;
cout << "x2 = " << x2 << endl;
}
else if (dtrmnt == 0) {
x1 = (-b + sqrt(dtrmnt)) / (2*a);
cout<<endl<<endl;
cout << "x1 = x2 =" << x1 << endl;
}
else {
real = -b/(2*a);
imgpart =sqrt(-dtrmnt)/(2*a);
cout<<endl<<endl;
cout << "x1 = " << real << "+" << imgpart << "i" << endl;
cout << "x2 = " << real << "-" << imgpart << "i" << endl;
}
return 0;
}
Output of the Program
Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.
0 comments:
Post a Comment