fork download
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5. int a,b,c;
  6. float root1,root2,disc;
  7. printf("\nEnter three numbers:");
  8. scanf("%d %d %d",&a,&b,&c);
  9. disc=b*b-4*a*c;
  10. if (disc==0)
  11. {
  12. printf("\nthe roots are real and equal");
  13. root1=root2=-b/(2.0*a);
  14. printf("The root1 is %f and root2 is %f \n",root1,root2);
  15. }
  16. else if(disc>0)
  17. {
  18. printf("\nThe roots are real and different");
  19. root1=(-b+sqrt(disc))/(2.0*a);
  20. root2=(-b-sqrt(disc))/(2.0*a);
  21. printf("\nThe root1 is %f and root2 is %f \n",root1,root2);
  22. }
  23. else
  24. {
  25. printf("\nthe roots are imaginary");
  26. }
  27. return 0;
  28.  
  29. }
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
Enter three numbers:
The roots are real and different
The root1 is 37433.925781 and root2 is 37432.597656