Showing posts with label PROGRAM to solve the quadratic equation using class. Show all posts
Showing posts with label PROGRAM to solve the quadratic equation using class. Show all posts

Thursday, 21 July 2011

PROGRAM to solve the quadratic equation using class

#include
#include
#include
float a1,b1,c1;
class quad
{
float a,b,c;
public:
void getinfo(float,float,float);
void display();
void equal(float a,float b);
void imag();
void real(float a,float b,float d);
};
void quad :: getinfo(float a1,float b1,float c1)
{
a=a1;
b=b1;
c=c1;
}
void quad :: display()
{
cout<<"\n a: "<>a1;
cout<<"\n Enter the cofficient of x : "; cin>>b1;
cout<<"\n Enter the constant term : "; cin>>c1;
q.getinfo(a1,b1,c1);
q.display();
if(a1==0)
{
float temp;
temp = c1/b1;
cout<<"\n Linear roots : "< }
else
{
float d;
d=b1*b1-(4*a1*c1);
if(d==0)
q.equal(a1,b1);
else if(d<0)
q.imag();
else
q.real(a1,b1,c1);
}
getch();
}