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 create an html page with frames and frameset

1. Write a program to insert a new element at end as well as at a given position in an array in Java

1. To familiarize with network devices like switch, hub, routers and bridges in LaTex