Tuesday 30 June 2015

Program 4 : Write a program to solve Quadratic Equation

#include<stdio.h>

#include<math.h>

void main()

{

    int a, b, c, d, X1, X2;

    printf(“Enter the a, b, c value / n”);

    scanf(“ %d, %d, %d”, &a, &b, &c);

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

    if (d > 0) 

    {

        X1 = (-b + (sqrt(d))) / (2 * a);

        printf(“X1 is : % d / n”, X1);

        X2 = (-b - (sqrt(d))) / (2 * a);

        printf(“X2 is : % d / n”, X2);

    }

 else

    {

        printf(“root value is negative / n”);

    }

}

No comments:

Post a Comment