Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #define CRT_SECURE_NO_WARNINGS
  4. void main()
  5. {
  6. float A, B, C, D, Root, X1, X2;
  7.  
  8. scanf_s("%f%f%f", &A, &B, &C);
  9.  
  10. D = (B*B) - (4 * A * C);
  11. Root = sqrt(D);
  12. X1 = ((-B) + Root) / (2*A);
  13. X2 = ((-B) - Root) / (2*A);
  14. Root2 = sqrt((-C / A));
  15. //(sqrt((B * B) - (4 * A*C))) / (2 * A);
  16.  
  17. printf(" %.1f %.1f %.1f %.1f %.1f %.1f %.1f\n", A, B, C, D, Root, X1, X2);
  18.  
  19. if ((Root < 0) || (A == 0))
  20. {
  21. if ((B == 0) && (A == 0))
  22. printf("X has no solution.\n");
  23. else
  24. {
  25. if (A == 0)
  26. printf("X = %.1f\n", ((-C) / B));
  27. else
  28. if (Root == 0)
  29. printf("X= %/1f\n", Root2);
  30. else // E<0
  31. printf("X has no solution.\n");
  32. }
  33. }
  34. else
  35. printf("X1= %.1f X2= %.1f\n", X1, X2);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement