Friday 26 June 2015

C PROGRAM TO FIND ROOTS OF QUADRATIC EQUATION WITH OUTPUT


C PROGRAM TO FIND ROOTS OF QUADRATIC EQUATION WITH OUTPUT
#include<stdio.h>
#include<math.h>
int main()
{
    float a,b,c,x,y,disc,p,q,r;
    printf("\n C PROGRAM TO FIND ROOTS OF QUADRATIC EQUATION ");
    printf("\n Enter the values of a,b,c : ");
    scanf("%f %f %f",&a,&b,&c);
    disc=(b*b)-(4*a*c);
    if(disc == 0)
    {
        x=(-b)/(2*a);
        y=x;
        printf("\n Roots are Equal..");
        printf("\n x= %f , y= %f\n",x,y);
    }
     else if(disc < 0)
    {
        p=(-b)/(2*a);
        q=sqrt(-disc)/(2*a);
        printf("\n Roots are Complex and Imaginary..");
        printf("\n x= %f+%fi , y= %f-%fi\n",p,q,p,q);
    } 
     else if(disc > 0)
    {
        r=sqrt(disc);
        x=((-b)+r)/(2*a);
        y=((-b)-r)/(2*a);
        printf("\n Roots are Real Numbers..");
        printf("\n x= %f , y= %f\n",x,y);
    }
    else if(a==0)
    {
      x=(-c)/b;
      printf("\n Root is x = %f\n ",x);
    }
    getchar();
    return 0;
}
--------------------------------------------------------------------------
sda@JKSFHG:~/Desktop$ gcc code.c -lm
sda@JKSFHG:~/Desktop$ ./a.out 

 C PROGRAM TO FIND ROOTS OF QUADRATIC EQUATION 
 Enter the values of a,b,c : 12
13
14

 Roots are Complex and Imaginary..
 x= -0.541667+0.934486i , y= -0.541667-0.934486i
sda@JKSFHG:~/Desktop$ 
---------------------------------------------------------

1 comment:

Unknown said...

I simply want to offer you a huge thumbs up for your great information. Geocodes, geographic search features and selection controls will make it easier to use maps to visualise your data in 9.0 you can also check this out http://www.sqiar.com/services/tableau-software-consultants/