fork(2) download
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4. int main()
  5. {
  6. float a,b,c,d,x1,x2,real,imag;
  7. printf("input:> \na b c:>\n");
  8. scanf("%f%f%f",&a,&b,&c);
  9. d=sqrt(b*b-4*a*c);
  10. if(d>0){
  11. x1=(-b+d)/(2*a);
  12. x2=(-b-d)/(2*a);
  13. printf("x=%.3f, %.3f",x1,x2);
  14. }
  15. else if(d==0){
  16. x1=x2=-b/(2*a);
  17. printf("x=%.3f, %.3f",x1,x2);
  18. }
  19.  
  20. else{
  21. real=-b/(2*a);
  22. imag=sqrt(-d/(2*a));
  23. printf("Roots are:> %.3f+%.3fi and %.3f-%.3fi",real,imag,real,imag);
  24. }
  25. return 0;
  26. }
  27.  
  28.  
Success #stdin #stdout 0s 2172KB
stdin
Standard input is empty
stdout
input:> 
a b c:>
Roots are:> nan+nani and nan-nani