fork download
  1. # include<stdio.h>
  2. # include<math.h>
  3.  
  4. int main () {
  5. float a,b,c,r1,r2,d;
  6.  
  7. printf ("Enter the values of a b c: ");
  8. scanf (" %f %f %f", &a, &b, &c);
  9.  
  10. d= b*b - 4*a*c;
  11.  
  12. if (d>0) {
  13. r1 = -b+sqrt (d) / (2*a);
  14. r2 = -b-sqrt (d) / (2*a);
  15. printf ("The real roots = %f %f", r1, r2);
  16. }
  17. else if (d==0) {
  18. r1 = -b/(2*a);
  19. r2 = -b/(2*a);
  20. printf ("Roots are equal =%f %f", r1, r2);
  21. }
  22. else
  23. printf("Roots are imaginary");
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 5276KB
stdin
2 
4
3
stdout
Enter the values of a b c: Roots are imaginary