0
quadratic equation
Can any one solve quadratic equation using do while loop in c++ language
11 ответов
+ 2
We are not writing code for people here.
But we do assist you, if you show us your honest attempt!
+ 2
I am out
Dont wanna copy&paste to see whats wrong.
Wake me up, if the code is available on SL playground
+ 2
In addition to aforementioned issues, I found:
- missing "using namespace std;"
- clrscr() not supported (remove it)
- getch() at end is useless in SoloLearn's batch run environment (remove it)
- missing ; after do/while statements
At run time it falls into an infinite loop when I enter 1 6 9 for a b c.
0
Yes we can
0
Pls do this
0
Can you tell us what sort of problems you ran into with your code?
(I see a few capitalized dos and whiles.)
0
Void main (void) is not accepting
0
That's normal. Have you tried int main?
0
and if you have a look inti your first prog here?
0
Int main is also not working
- 1
#include<iostream>
#include<math.h>
void main(void)
{
clrscr();
double a,b,c,d,r1,r2; //ax^2+bx+c , d=b*b-4ac
cout<<"Enter value of a"<<endl;
cin>>a;
cout<<"Enter value of b"<<endl;
cin>>b;
cout<<"Enter value of c"<<endl;
cin>>c;
d=b*b-4*a*c;
Do{
cout<<"Real root"<<endl;
r1=4*a*c/(2*a*(-b+sqrt(d)));
r2=4*a*c/(2*a*(-b-sqrt(d)));
cout<<"Root 1 "<<r1<<"Root 2 "<<r2<<endl;
}
While(d>0)
Do{
cout<<"Same root"<<endl;
r1=4*a*c/(2*a*(-b+sqrt(d)));
r2=4*a*c/(2*a*(-b-sqrt(d)));
cout<<"Root 1 "<<r1<<"Root 2 "<<r2<<endl;
}
While(d==0)
Do{
cout<<"image"<<endl;
r1=4*a*c/(2*a*(-b+sqrt(d)));
r2=r1;
cout<<"Root 1 "<<r1<<"Root 2 "<<r2<<endl;
}while(d<0)
getch () ;
}