Thursday 31 January 2013

roots of quad eq; in c++ by Zafar iqbal lavi

include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,disc,root1,root2;
cout<<"enter a"<<endl;
cin>>a;
cout<<"enter b"<<endl;
cin>>b;
cout<<"enter c"<<endl;
cin>>c;
disc=(b*b)-(4*a*c);
root1=(-b+sqrt(disc))/(2*a);
root2=(-b-sqrt(disc))/(2*a);
cout<<"root1"<<root1<<endl;
cout<<"root2"<<root2<<endl;
getch();
}

0 comments:

Post a Comment