/* Q.N 1. Write a C++ code to solve the quadratic equations . */
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<iostream.h>
class qequ
{
int a,b,c;
float root1,root2;
public:
void getdata(int ,int ,int);
void calroot();
void disp();
};
void qequ::getdata(int x,int y,int z)
{
a=x;
b=y;
c=z;
}
void
main()
{
int a,b,c;
float d,root1,root2;
cout<<"\nEnter The Value Of a , b & c from Equation : ";
cin>>a>>b>>c;
d=sqrt(b*b-4*a*c);
if(d<0)
cout<<"\nThe Roots Are Imaginarry !";
else
{
root1=((-b+d)/2*a);
root1=((-b+d)/2*a);
cout<<"\nThe Roots Are : ";
cout<<"\nRoot 1 : "<<root1;
cout<<"\nRoot 2 : "<<root2;
}
getch();
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment