quadratic equation | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

quadratic equation

Can any one solve quadratic equation using do while loop in c++ language

17th Feb 2020, 4:46 PM
sakib shaikh
sakib shaikh - avatar
11 Answers
+ 2
We are not writing code for people here. But we do assist you, if you show us your honest attempt!
17th Feb 2020, 5:44 PM
HonFu
HonFu - avatar
+ 2
I am out Dont wanna copy&paste to see whats wrong. Wake me up, if the code is available on SL playground
17th Feb 2020, 5:58 PM
Oma Falk
Oma Falk - avatar
+ 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.
17th Feb 2020, 7:31 PM
Brian
Brian - avatar
0
Yes we can
17th Feb 2020, 5:26 PM
Salim Largo
Salim Largo - avatar
0
Pls do this
17th Feb 2020, 5:39 PM
sakib shaikh
sakib shaikh - avatar
0
Can you tell us what sort of problems you ran into with your code? (I see a few capitalized dos and whiles.)
17th Feb 2020, 5:46 PM
HonFu
HonFu - avatar
0
Void main (void) is not accepting
17th Feb 2020, 5:47 PM
sakib shaikh
sakib shaikh - avatar
0
That's normal. Have you tried int main?
17th Feb 2020, 5:51 PM
HonFu
HonFu - avatar
0
and if you have a look inti your first prog here?
17th Feb 2020, 5:51 PM
Oma Falk
Oma Falk - avatar
0
Int main is also not working
17th Feb 2020, 5:55 PM
sakib shaikh
sakib shaikh - avatar
- 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 () ; }
17th Feb 2020, 5:44 PM
sakib shaikh
sakib shaikh - avatar