+ 1

Who can help me? I want to write if(b==0 && c==0) { printf("x=0"); } but when I write this my program don't work!

https://code.sololearn.com/c5muJyJh8JyI/?ref=app

26th Nov 2019, 11:23 PM
Erik Margaryan
Erik Margaryan - avatar
12 Answers
+ 6
There is mistake in a*x*x=0 Because this is rule in c that only one variable should be on left of the assignment operator(=). So a*x*x=0 is not possible because it is invalid
27th Nov 2019, 12:43 AM
ツSampriya😘ツ
ツSampriya😘ツ - avatar
+ 2
Try to use double in place of float. Comparison of float value against a literal (such as 0) usually fails due to the fact that the literal 0 is by default a double type value. Difference of precision accuracy between float and double is the cause, most of the times.
27th Nov 2019, 12:49 AM
Ipang
+ 1
Erik Margaryan To be honest I don't think I'm understanding your code. Maybe it's because I'm no good in math. Can you tell me what exactly is this code doing? maybe I can help further if I can understand it (hope so).
27th Nov 2019, 2:42 PM
Ipang
+ 1
ax²+bx+c=0 a,b,c are constant. When a=0 => x = -c/b and b ≠ 0, When b=0 => ax²+c=0, x²=-c/a, x1, x2 = ±√(-c)/a => c or a have to less than 0 and a ≠ 0. When c=0 => ax² +bx=0, x(ax+b)=0 => x1=0 and x2=(-b)/a and a≠0. Discriminate means 'D' symbol.. When a≠0 and b≠0 and c≠0 then D=b²+4ac, When D<0 then x=ø, When D>0 then X1, X2 = (-b ± √D)/2a This is "Square Equation". You can search Square Equation by Google for understand better! Now I want to write when b=0 and c=0 => ax² = 0 => x=0. But my program don't work!
27th Nov 2019, 4:44 PM
Erik Margaryan
Erik Margaryan - avatar
+ 1
Thanks Erik Margaryan , I think I should've learn that square equation first before I commented XD I hope someone knowledgeable sees your post and help you with it. Good luck! 👍
27th Nov 2019, 4:55 PM
Ipang
0
But who can answer me which line to write that? if(b==0 && c==0) { printf("x=0"); }
27th Nov 2019, 2:36 PM
Erik Margaryan
Erik Margaryan - avatar
0
I write that different lines and output is: X=0 X_1=..... X_2=.... ..... But I need only x=0.
27th Nov 2019, 2:38 PM
Erik Margaryan
Erik Margaryan - avatar
0
Thanks!! I hope too.
27th Nov 2019, 5:09 PM
Erik Margaryan
Erik Margaryan - avatar
0
Sees my program again! I already find my error.🥳
28th Nov 2019, 6:48 PM
Erik Margaryan
Erik Margaryan - avatar
0
هبص
28th Nov 2019, 7:27 PM
Mhmoed NazehŘş
17th Dec 2019, 7:48 PM
Erik Margaryan
Erik Margaryan - avatar
0
See of my program more improve version!👏
17th Dec 2019, 7:48 PM
Erik Margaryan
Erik Margaryan - avatar