+ 4

can someone finish the d<0 part

#include <stdio.h> #include <conio.h> #include <math.h> main() { float a,b,c,d,x,x1,x2,r; printf("The value of a="); scanf("%f" ,&a); printf("The value of b="); scanf("%f" ,&b); printf("The value of c="); scanf("%f" ,&c); if(a==0) { x=-(c/b); printf("\n\tThis is not a quadrical equation"); printf("\n\tIt has only one root i.e=%f" ,x); } if(a!=0) { d=sqrt(b*b-4*a*c); if(d<0) { printf("\nThis equation has no real roots"); r=(sqrt(abs(d))/(2*a)); printf("\n\t x1

21st Feb 2018, 2:29 PM
MD. JAFRUL HASSAN ANGEL
MD. JAFRUL HASSAN ANGEL - avatar
1 Answer
+ 21
#include <stdio.h> #include <conio.h> #include <math.h> int main() { float a,b,c; printf("The value of a=\n"); scanf("%f" ,&a); printf("The value of b=\n"); scanf("%f" ,&b); printf("The value of c=\n"); scanf("%f" ,&c); if(a==0) { float x=-(c/b); printf("\n\tThis is not a quadrical equation"); printf("\n\tIt has only one root i.e=%f" ,x); } if(a!=0) { float d=b*b-4*a*c; if(d<0){ printf("\nThis equation has no real roots");} else if(d==0){ printf("Solution:%f",-b/2*a);} else{ printf("Solution:%f %f",(-b-sqrt(d))/(2*a),(-b+sqrt(d))/(2*a));}} return 0; }
28th Feb 2018, 6:14 PM
Mert Yazıcı
Mert Yazıcı - avatar