#include
void roots(float a, float b, float c);
int main()
{
float a,b,c;
printf("Enter a value: ");
scanf("%f",&a);
printf("Enter b value: ");
scanf("%f",&b);
printf("Enter c value: ");
scanf("%f",&c);
printf("The quadratic equation is: (%.1f) x^2 + (%.1f) x + (%.1f) \nRoots for the above equation are: ",a,b,c);
roots(a,b,c);
return 0;
}
void roots(float a, float b, float c)
{
if((pow(b,2) - (4 * a * c)) < 0)
{
printf("\nRoots are complex numbers \n");
}
else
{
printf("\nRoot1 = %.2f",(((-1 * b) + sqrt((pow(b,2) - (4 * a * c))))/2*a));
printf("\nRoot2 = %.2f\n",(((-1 * b) - sqrt((pow(b,2) - (4 * a * c))))/2*a));
}
}