Write a program that solves a quadratic equation gives the answer for the roots.

      

Write a program that solves a quadratic equation gives the answer for the roots.

  

Answers


Martin
#include
#include
#include
float main()
{
float a, b, c, d, x1, x2;
printf("Enter the value of the coefficient of x^2 , x, and c respectively\n");
scanf("%f%f%f", &a, &b, &c);
if (a!=0)
{


d=sqrt(b*b - 4 *a*c);
x1=(-b+d)/(2*a);
x2=(-b-d)/(2*a);
printf("The value of x is equal to %.2f\n and\n %.2f", x1, x2);
}
else
{
printf("\t\t\t\n\n\n\n\a*****Since the value of the coefficient of x^2 is zero, hence the equation ain't a quadratic equation*****\n\n\n");

}
return 0;
}
Joshua_white answered the question on March 8, 2018 at 08:41


Next: Write a C++ program that accepts an integer and checks whether it is even or odd and then prints an appropriate message
Previous: Describe how the counter current flow maintains the partial pressure of oxygen in the gills of fish

View More Computer Science Questions and Answers | Return to Questions Index


Exams With Marking Schemes

Related Questions