#include <stdio.h>
#include <math.h>

int main()
{
int a,b,c,p;
int d ,root1,root2,s;
    
printf("enter the cofficient of x^2 in quadratic equation:\n ");
    scanf("%d", & a);
printf("enter the cofficient of x in quadratic equation:\n");
    scanf("%d", & b);
printf("enter the cofficientof the constant in quadratic equation:\n");
     scanf("%d", & c);
printf("the given quadratic equation is %dx^2+%dx+%d=0\n",a,b,c); 
p=pow(b,2);
d=p-4*(a*c);
printf("d=%d",d);
    if(d>0)
    {
        s=sqrt(d);
            root1=(-(b)+s)/(2*(a));
        root2=(-(b) -s )/(2*(a));
        printf("the real roots are %d,%d\n",root1, root2);
    }
        else if (d==0)
        {
        root1=(-b)/(2*a);
            root2=(-b)/(2*a);
            printf("the roots are not equal:%d%d",root1,root2);
        }
    else{
    printf("the root are imajinary\n");
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: