Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <windows.h>
- void RootsofQuadratic(int a, int b, int c)
- {
- if (a == 0)
- {
- printf("The value of a cannot be 0");
- return;
- }
- int d = b*b - 4*a*c;
- double SquarerootDescriminant = sqrt(abs(d));
- if (d > 0)
- {
- printf("The Roots are Real in Nature n");
- printf("%fn%f",(double)(-b + SquarerootDescriminant)/(2*a)
- , (double)(-b - SquarerootDescriminant)/(2*a));
- }
- else if (d == 0)
- {
- printf("The roots are equal and Real in Nature n");
- printf("%f",-(double)b / (2*a));
- }
- else // d < 0
- {
- printf("The Roots are Complex in Nature n");
- printf("%f + i%fn%f - i%f", -(double)b / (2*a),SquarerootDescriminant
- ,-(double)b / (2*a), SquarerootDescriminant);
- }
- }
- int main()
- {
- int a;
- int b;
- int c;
- printf("For a quadratic equation of form ax2 + bx + c = 0 enter values of a, b, cn");
- scanf("%d%d%d", &a, &b, &c); /*Asking for input*/
- RootsofQuadratic(a, b, c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement