**C program to find roots of quadratic equation** : In **mathematics**, quadratic equation is second degree univariate polynomial equation. A general quadratic equation can be represented by :

where a, b and c are the coefficients of quadratic equation and a ≠ 0 . If a = 0 then it will be linear **equations**.

Now the solutions of **quadratic equation** can have distinct roots, equal roots or complex roots depending upon the value of discriminant.

Discriminant of a quadratic equation is an constant value equal to **b^2 -4ac**. Now,

If Discriminant>0, then quadratic equation will have distinct roots.

If Discriminant=0, then Quadratic equation will have equal roots.

If Discriminant<0, then Quadratic equation will have complex roots.

I have written a **C program to find roots of quadratic equation** which accepts coefficients of quadratic equation as input and calculates and displays the roots of quadratic equation.

Platform : C Language

Compiler : Dev C++

**C program to find roots of quadratic equation** :

#include<stdio.h> #include<conio.h> #include<math.h> #include<process.h> int main() { float a,b,c,x1,x2,disc; printf("-------------------------------------------------------------\n"); printf("----------------made by C code champ ------------------------\n"); printf("-------------------------------------------------------------\n"); printf("\n C Program for Calcualting roots of Quadratic Equation\n\n"); printf("Enter coefficient of X^2 : "); scanf("%f",&a); printf("\nEnter coefficient of X^1 : "); scanf("%f",&b); printf("\nEnter coefficient of X^0 : "); scanf("%f",&c); /*Finding discriminant*/ disc=b*b-4*a*c; /*distinct roots*/ if(disc>0) { x1=(-b+sqrt(disc))/(2*a); x2=(-b-sqrt(disc))/(2*a); printf("\nThe roots are distinct\n"); printf("x1=%f\nx2=%f\n",x1,x2); getch(); exit(0); } /*Equal roots*/ if(disc==0) { x1=x2=-b/(2*a); printf("\nThe roots are equal\n"); printf("x1=%f\nx2=%f\n",x1,x2); getch(); exit(0); } /*complex roots*/ x1=-b/(2*a); x2=sqrt(fabs(disc))/(2*a); printf("\nThe roots are complex.\n"); printf("The first root=%f+i%f\n",x1,x2); printf("The second root=%f-i%f\n",x1,x2); getch(); }

We hope you all have enjoyed the **C program to find roots of quadratic equation**. If you have any issues or concerns with the logic ask us in form of comments.

A wonrdeful job. Super helpful information.

I every time emailed this website post page to all my contacts, as if like to read it afterward my links will too.

Nice post. I learn something new and challenging on websites I stumbleupon everyday. It will always be exciting to read articles from other writers and use something from their websites.

just beneath, are numerous totally not related sites to ours, however, they are surely worth going over.

plz explain the code

x2=sqrt(fabs(disc))/(2*a);

what is “fabs” meaning?

Fabs function is function absolute value function defined under math.h. It is used to calculate absolute value of arg.

Say num = -1234.00 then its absolute value will be 1234 i.e. fabs(num) =1234.

pls tell me c program

*

* *

* * *

* * * *

* * * * *

* * * *

* * *

* *

*

Now users go on to you slightly than finding you in a search engine and

you may benefit from in-app advertising, seeing an uptick in income if

your app is particularly in style.