• Saturday, October 5, 2013

    Solve Quadric equation using C programming

    Here you get a program that calculate the solution of quadric equation......
    #include <stdio.h>;
    #include <conio.h>;
    main()
    {
    float a,b,c,x1,x2,disc;
    clrscr();

    printf("Enter the value of a,b,c: ");
    scanf("%f%f%f",&a,&b,&c);
    disc = b*b - 4 * a * c ;
    if(disc >0 )
    {
    x1= (-b + sqrt(disc))/ (2 * a);
    x2 = (-b - sqrt(disc))/(2*a);
    printf("\nThe root are distinct\nAndvalue are as follows:\nx1 = %f\nx2 =%f",x1,x2);
    }
    if(disc == 0){x1=x2=-b/(2*a);
    printf("\nRoot are equal and value of x1=x2=%f",x1);
    }
    if(disc <0)
    {
    x1= -b /(2*a) ;
    x2 = sqrt(fabs(disc));
    printf("\nRoot are complex. Values are:\nx1=%f\nx2=%f",x1,x2);
    }
    getch();
    }
    }

    Syed Masoom Rizvi

    Author & Editor

    Hi, This is Syed Masoom Rizvi, who is continue exploring the world of programming ,programming and programming... :)

    0 comments:

    Post a Comment