Video courses for company/skill based Preparation
Purchase mock tests for company/skill building
Roots Of A Quadratic Equation
Finding Roots of a Quadratic Equation
In this C program, we will find the roots of a quadratic equation [ax2 + bx + c]. We can solve a Quadratic Equation by finding its roots. Mainly roots of the quadratic equation are represented by a parabola in 3 different patterns like :
- No Real Roots
- One Real Root
- Two Real Roots
We get the roots of the equation which satisfies any one of the above conditions :
X = [-b (+or-)[Squareroot(pow(b,2)-4ac)]]/2a
Sample Test Case
Enter value of a :1
Enter value of b :-7
Enter value of c :12
Two Real Roots
- Take input from user a,b,c.
- Check the value of a i.e. a!=0.
- Calculate Discriminant (D)
- D = b^2 – 4*a*c
- If D>0 : Two real root exists.
- If D=0 : Equal root exists.
- If D<0 : Imaginary root exists.
- Display the existence of roots and the roots of the equation.
This page is contributed by Rishav Raj