C program to compute roots Quadratic Equation.

 



#include <stdio.h>

#include <math.h>


int main()

{

    int a,b,c,d;

    float x1,x2;

    printf("enter value of a,b,c ");

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

    d=pow(b,2)-4*a*c;

    if(d>=0){

        if(d>0){

            x1=-b+pow(d,1/2)/2*a;

            x2=-b-pow(d,1/2)/2*a;

            printf("x1=%.2f,x2=%.2f",x1,x2);

        }else{

            x1=x2=-b/2*a;

            printf("x1=x2=%.2f",x1);

        }

    }else{

        printf("roots are _Imaginary");

        

    }


    return 0;

}


No comments:

Post a Comment

Programming in C Language

  PROGRAM LIST TO BECOME PRO IN C    😍😍😍            PRACTICE SETS                                                        UNIT -1  👇   IN...