SOLUTION: please help me with a C program source code that works out the roots a quadratic equation in the form {{{ax^2+bx+c=0}}}

Algebra.Com
Question 134103: please help me with a C program source code that works out the roots a quadratic equation in the form
Answer by solver91311(24713)   (Show Source): You can put this solution on YOUR website!
This is C++, hope it helps:

=======================================================
/*
This is a quadratic equation solver,this program can be use to solve
second-order polynomial equation with one variable "x"
written by: Gonzales Cenelia
website: www.ai-search.4t.com
*/

#include
#include
#define sqr(x) (x)*(x)
#define clrscr() system("cls");

int main()
{
intro:
std::cout << "\t\t\tQUADRATIC EQUATION SOLVER\n\n";
std::cout << "ENTER COEFFICIENTS:\n";
float A, B, C, Delta;
std::cout << " A = ";
std::cin >> A;
std::cout << " B = ";
std::cin >> B;
std::cout << " C = ";
std::cin >> C;
std::cout << std::endl;
if(A == 0 && B != 0)
{
std::cout << "THIS EQUATION IS A FIRST DEGREE EQUATION\n";
std::cout << "THE SOLUTION IS: " << -C/B << std::endl;
}
else if(A == 0 && B == 0)
{
std::cout << "THIS EQUATION HAS NO SOLUTION";
}
else
{
Delta = sqr(B) - 4*A*C;
if(Delta < 0)
{
std::cout << "THIS EQUATION DONT HAVE ANY REAL ROOTS";
}
else if(Delta == 0)
{
std::cout << "THIS EQUATION HAVE A SINGLE ROOT: " << -B/(2*A) << std::endl;
}
else
{
std::cout << "THIS EQUATION HAVE TWO REAL ROOTS" << std::endl;

float X1 = (-B + sqrt(Delta)) / (2 * A);
float X2 = (-B - sqrt(Delta)) / (2 * A);
std::cout << " X1 = " << X1 << std::endl;
std::cout << " X2 = " << X2 << std::endl;
}
}
std::cout << "\nDO YOU WANT TO SOLVE ANOTHER EQUATION?\nYes(y) No(n): ";
fflush(stdin); // flush input buffer
int sel = tolower(getchar());
while(sel != 'y' && sel != 'n')
{
std::cout << "\nWRONG SELECTION,PLEASE CHOOSE \"y\" FOR \"YES\" OR \"n\" FOR \"NO\": " << std::endl;
fflush(stdin); // flush input buffer
sel = tolower(getchar());
}
if(sel == 'y')
{
clrscr();
goto intro;
}
std::cout << "\nTHANKS FOR USING THIS PROGRAM!" << std::endl;
return 0;
}

RELATED QUESTIONS

Write a quadratic equation in the form ax^2 + bx + c = 0 with the given roots: -1/2, 5. (answered by Mathtut)
Write a quadratic equation with the roots + or - radical5/4. write equation in the form... (answered by richard1234)
How do I write a quadratic equation with the given roots (2/3) and -4 in the form of... (answered by ankor@dixie-net.com)
Write a quadratic equation with -3/4 and 4 as its roots. write the equation in form... (answered by Fombitz)
how do i solve... directions: write a quadratic equation with the given roots. Write the (answered by Alan3354,richard1234)
Please help me with these questions : 1) The equations ax^2 +bx+c =0 and bx^2 +ax+c=0... (answered by KMST)
Please I need help with: quintun was solving a quadestic equation in the form ax^2+bx+c=0 (answered by Edwin McCravy)
Find a quadratic equation in the form ax^2 + bx + c = 0, where a, b and c are integers... (answered by ankor@dixie-net.com)
Write a quadratic equation in the form of ax^2 + bx + c = 0 that has 2 - i as a... (answered by josgarithmetic)