by Sanchit Karve
Prints the Solution of a Quadratic Equation on Screen as you would solve it using Factorisation. The quadratic equation is solved by using various equations embedded in the program to get you the desired output. Each and every step is visible as it would be solved on paper.
void main()
{
cout<<” Quadratic Equation Calculator”<<endl<<” by Sanchit
Karve”<<endl<<endl;
float a,b,c,x,y;
cout<<” Equation must be in the form of ax²+bx+c=0″<<endl<<endl;
cout<<” Please enter the value of a: “;
cin>>a;
cout<<” Please enter the value of b: “;
cin>>b;
cout<<” Please enter the value of c: “;
cin>>c;
x=((-b+sqrt((b*b)-(4.0*a*c)))/(2.0*a));
y=((-b-sqrt((b*b)-(4*a*c)))/(2*a));
clrscr();
cout<<“HERE IS THE SOLUTION USING FACTORISATION
“;
cout.setf(ios::showpos);
float mul=(x*-1)*(y*-1);
cout<<” x²”<<(y*-1)+(x*-1)<<“x”<<mul<<“=0
“;
cout<<” x²”<<y*-1<<“x”<<x*-1<<“x”<<(x*-1)*(y*-1)<<“=0
“; //
x²+2x-1x-2=0
cout<<” x(x”<<y*-1<<“)”<<x*-1<<“(x”<<y*-1<<“)=0
“; // x(x+2)-1(x+2)
cout<<” (x”<<x*-1<<“)(x”<<y*-1<<“)=0
“; // (x-1) (x+2)=0
cout.unsetf(ios::showpos);
cout<<” x=”<<x<<” & x=”<<y<<”
“;
cout<<”
Sanchit Karve
born2c0de@hotmail.com”;
exit(EXIT_SUCCESS);
}