Turbo C Quadratic Equation

Hi. Good Day.

Is there anybody who can help me with my project in turbo C....
The logic must be like this, THE USER WILL INPUT A QUADRATIC EQUATION AND IT WILL BE DETERMINED IF THE EQUATION IS FACTORABLE OR NOT.

THE OUTPUT MUST BE LIKE THIS:
IF FACTORABLE THEN
SOLVE THE EQUATION
PRINT THE ANSWER
ELSE THEN
PRINT "THE EQUATION IS NOT FACTORABLE"

Any help...thanx a lot.

Comments

  • #include
    #include
    main()
    {
    int a,b,c;
    float x1,x2,D;
    printf("Enter the Values of a,b,c:");
    scanf("%d%d%d",&a,&b,&c);
    D=b*b-4*a*c;
    if(D==0)
    {
    printf("THE EQUATION IS FACTORABLE and the Roots are equal.
    ");
    x1= -b/(2*a);
    printf("Root=%f
    ",x1);
    }
    else if(D<0)
    {
    printf("THE EQUATION IS NOT FACTORABLE.
    ");
    x1=-b/(2*a);
    x2=sqrt(-D)/2*a;
    printf("Roots are %f+%fi and %f-%fi
    ",x1,x2,x1,x2); }
    else if(D>0)
    {
    x1=(-b+sqrt(D))/(2*a);
    x2=(-b-sqrt(D))/(2*a);
    printf("THE EQUATION IS FACTORABLE.
    ");
    printf("Roots are %f and %f
    ",x1,x2);
    }
    else
    {
    printf("The given equation is linear.
    ");
    x1=-c/b;
    printf("Root=%f
    ",x1);
    }
    }


    Essays & Dissertations Qualified
    South Carolina University
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion