guys i tried constructing a programe and did but the problem when i run it the screen disappears and no output is presented. I am posting in the question as well as the script which i wrote,please send a reply to me abt it.
question is:
using if statement,to print the roots of a quadratic equation,given the condition as follows:
IF ROOTS
b*b-4*a*c>0 {-b(+/-)sqrt(b*b-4*a*c)}/2*a
b*b-4*a*c=0 {-b/2*a} (msg=roots are equal)
b*b-4*a*c<0 roots are imaginary
script which i had typed:
#include<iostre am.h>
#include<conio. h>
#include<math.h >
void main()
{
clrscr();
float a,b,c,r1,d,r2,e ;
cout<<"\n enter the values of three no.s";
cin>>a>>b>>c;
d=b*b-4*a*c;
e=sqrt(d);
r1=(-b+e)/(2*a);
r2=(-b+e)/(2*a);
cout<<"\n root1="<<r1;
cout<<"\n root2="<<r2;
if (d>0)
cout<<"\n "<<r2;
else
{
if (d==0)
cout<<"\n roots are equal"<<r1;
}
if (d<0)
cout<<"\n roots are imaginary";
getch();
}
question is:
using if statement,to print the roots of a quadratic equation,given the condition as follows:
IF ROOTS
b*b-4*a*c>0 {-b(+/-)sqrt(b*b-4*a*c)}/2*a
b*b-4*a*c=0 {-b/2*a} (msg=roots are equal)
b*b-4*a*c<0 roots are imaginary
script which i had typed:
#include<iostre am.h>
#include<conio. h>
#include<math.h >
void main()
{
clrscr();
float a,b,c,r1,d,r2,e ;
cout<<"\n enter the values of three no.s";
cin>>a>>b>>c;
d=b*b-4*a*c;
e=sqrt(d);
r1=(-b+e)/(2*a);
r2=(-b+e)/(2*a);
cout<<"\n root1="<<r1;
cout<<"\n root2="<<r2;
if (d>0)
cout<<"\n "<<r2;
else
{
if (d==0)
cout<<"\n roots are equal"<<r1;
}
if (d<0)
cout<<"\n roots are imaginary";
getch();
}
Comment