A polynomial in x of at most degree 2 is given by ax 2 + bx +c its discriminant is defined to be b 2 – 4*a*c We are interested in the squareroot of the discriminant.

#include <stdio.h>

#include <math.h>

int main()

{

   int a,b,c,u;

   float z,x,y,j,k;

   printf("enter three numbers : \n");

   scanf("%d%d%d",&a,&b,&c);

       u= (b)*(b)-4*(a)*(c);

               if(u>0)

                    {

                      printf("it has two real roots");

                      z=b/(2*a);

                      x=(-b)/(2*a);

                      printf("roots are %d  , %d",z,x);

                    }

                if (u<0)

                  {

                      printf("it has two imaginary roots");

                      j=(b/(2*a));

                      k=(-b)/(2*a);

                      printf("roots are %fi, %fi",j,k);

                  }

                if (u==0)

                  {

                       printf("it has one real root.\n");

                       y=-b/(2*a);

                        printf("root is %d",y);

                  }

}
A polynomial in x of at most degree 2 is given by ax 2 + bx +c its discriminant is defined to be b 2 – 4*a*c We are interested in the squareroot of the discriminant. A polynomial in x of at most degree 2 is given by  ax 2 + bx +c  its discriminant is defined to be  b 2 – 4*a*c  We are interested in the squareroot of the discriminant. Reviewed by Unknown on 03:30 Rating: 5

No comments:

Powered by Blogger.