Tuesday, October 21, 2014

ax^2+bx+c=0

                             /* ax^2+bx+c=0*/
#include<stdio.h>
#include<math.h>
#include<conio.h>
void main()
{
     int a,b,c,d;
     float x1,x2;
     clrscr();
     printf("\n enter the value of a,b,c=");
     scanf("%d %d %d",&a,&b,&c);

     d=(b*b-4*a*c);
     printf("d=%d\n ",d);
     if(d>=0)
     {
        x1=(-b+sqrt(d))/2*a;
        x2=(-b-sqrt(d))/2*a;
     }
     else
     printf("The root is complex\n");
    printf("The root of x1 is %f and x2 is=%f",x1,x2);
}

No comments:

Post a Comment