a quadratic is usually written in the form ax 2 + bx + c = 0 The discriminate of
ID: 3642034 • Letter: A
Question
a quadratic is usually written in the form ax2 + bx + c = 0
The discriminate of the equation is d = b2 -4ac the equation can have zero, one or two real solutions depending on the value of d
Value of d Real solution
negative none
zero one x = -b/2a
write a program in C to calulate the root(s) of the equation or say there are no real solution. The program should then ask the user if he wishes to enter new data
Explanation / Answer
#include #include void main() { int a, b, c; float d, de, x1, x2; char ch; clrscr(); do { printf(" ENTER THE VALUES OF a,b,c"); scanf("%d,%d,%d", &a, &b, &c); d = (b * b) - (4 * a* c); de = 2 * a; if(d > 0) { printf(" THE ROOTS ARE REAL ROOTS"); x1 = (-b/de) + (sqrt(d) / de); x2 = (-b/de) - (sqrt(d) / de); printf(" THE ROOTS ARE...: %f and %f ", x1, x2); } else if(d == 0) { printf(" THE ROOTS ARE REPEATED ROOTS"); x1 = -b/de; printf(" THE ROOT IS...: %f ", x1); } else printf(" THE ROOTS ARE IMAGINARY ROOTS "); printf("y to continue.."); scanf("%c",ch); } while(ch=='y'||ch=='Y') getch(); }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.