کد برنامه نویسی پیدا کردن ضرایب معادله درجه دوم در c
#include <stdio.h>
#include <stdlib.h>
#include"math.h"
float a,b,c,delta,x1,x2,x;
main()
{
printf("Please enter the values of the quadratic equation in order\n");
printf("ax^2+bx+c=0\n");
printf("a=");
scanf("%f",&a);
printf("b=");
scanf("%f",&b);
printf("c=");
scanf("%f",&c);
if(a==0)
{
if(b==0)
{
printf("This is not an equation\n");
}
else
{
x = -c/b;
printf("The equation is prime\n");
printf("x=%f\n",x);
}
}
else
{
delta = (b*b) - 4*a*c;
if(delta==0)
{
printf("This equation has a root\n");
x = -b/(2*a);
printf("x=%f\n",x);
}
else
{
printf("This equation has two roots\n");
x1=(-b+sqrt(delta))/(2*a);
x2=(-b-sqrt(delta))/(2*a);
printf("x1 = %f\n",x1);
printf("x2 = %f\n",x2);
}
}
return 0;
}