Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #define CRT_SECURE_NO_WARNINGS
- void main()
- {
- float A, B, C, D, Root, X1, X2;
- scanf_s("%f%f%f", &A, &B, &C);
- D = (B*B) - (4 * A * C);
- Root = sqrt(D);
- X1 = ((-B) + Root) / (2*A);
- X2 = ((-B) - Root) / (2*A);
- Root2 = sqrt((-C / A));
- //(sqrt((B * B) - (4 * A*C))) / (2 * A);
- printf(" %.1f %.1f %.1f %.1f %.1f %.1f %.1f\n", A, B, C, D, Root, X1, X2);
- if ((Root < 0) || (A == 0))
- {
- if ((B == 0) && (A == 0))
- printf("X has no solution.\n");
- else
- {
- if (A == 0)
- printf("X = %.1f\n", ((-C) / B));
- else
- if (Root == 0)
- printf("X= %/1f\n", Root2);
- else // E<0
- printf("X has no solution.\n");
- }
- }
- else
- printf("X1= %.1f X2= %.1f\n", X1, X2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement