Program to find all roots of quadratic equations.

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
float a,b,c,d,e;
cout<<"Enter the values of a,b,c"<<endl;
cin>>a>>b>>c;
d=(sqrt(pow(b,2)-(4*a*c)));
float f=(-b+d)/(2*a);
float g=(-b-d)/(2*a);
cout<<"for - "<<g<<endl<<"for + "<<f<<endl;
e=pow(b,2)-(4*a*c);
if (e>0)
cout<<"real and unequal\n\n";
else if(e<0)
cout<<"imaginary\n\n";
else
cout<<"real and equal\n\n";
cout<<"/*\nName-Sanjampreet Singh\nRoll Number-1507967\n*/";
}

Output:


Comments

Popular posts from this blog

To implement the various components of HTML5 Canvas

Program to illustrate the concept of templates.

Program to illustrate the order of execution of constructors and destructors in inheritance.