Write a c program to find the roots of a quadratic equation








#include<stdio.h>
#include<math.h>
int main(){
    int a,b,c;
    double x,y,d;

    printf("Enter a , b , c of quadratic equation: ");
    scanf("%d%d%d",&a,&b,&c);

    //calculating the value of d
    d = sqrt(b * b - 4 * a * c);

    //Checking real solution is possible or not
    if(d<0){
         printf("Real number root is not possible");
         exit(1);
    }
    //finding the root of quadractic equation
    x = (-b + d) / 2 * a;
    y = (-b - d) / 2 * a;

    //printing the root of the quadractic equation
    printf("Solution of quadratic equation are %lf , %lf",x,y);

   
    return 0;
}





3 comments:

bibhu said...

in gcc compiler(ubuntu 15.03) it is not working

Raj Patel said...

Help me to solve this,,...

Declare and write a function that changes the value of the passed in argument, so that the caller of the function gets the changes from outside.

Rock World said...
This comment has been removed by the author.