

The function roots_of_equation has been defined to calculate the Discriminant value and to check the conditions after the Discriminant value has been calculated. In the above program, we have set the value of a, b, and c, instead, we can also take the value from the user. Print("Input correct Quadratic Equation") # If a is given 0, then Equation is incorrect # We can ask the user for value for a, b, c If D = 0, then the roots are real and equal.If D > 0, then the roots are real and distinct.The discriminant of the quadratic equation is D = b 2 – 4ac.The form ax 2 + bx + c = 0 will be followed, as this is the standard form.Some of the important points which should be followed for solving the quadratic equations are: The formula to find the roots of the quadratic equation is:

For solving the quadratic equation, we can directly apply the formula to find the roots. Solving Quadratic Equation using FormulaĪs discussed above, the quadratic equation intakes three parameters. Some of the topics which will be helpful for understanding the program implementation better are:Ģ. Input : a = 4, b = 2, c = 5 Output : Real and Different Roots Two Distinct Complex Roots Exists: root1 = -0.75+1.39 and root2 = -0.75-1.In this program, we will use the given coefficients a, b and c to calculate the roots of a quadratic equation. The output of the above c program as follows: Please Enter values of a, b, c of Quadratic Equation : 2 3 5 Printf("\n Two Equal and Real Roots Exists: root1 = %.2f and root2 = %.2f", root1, root2) Printf("\n Two Distinct Complex Roots Exists: root1 = %.2f+%.2f and root2 = %.2f-%.2f", root1, imaginary, root2, imaginary) Printf("\n Two Distinct Real Roots Exists: root1 = %.2f and root2 = %.2f", root1, root2) Root2 = (-b - sqrt(discriminant) / (2 * a)) Root1 = (-b + sqrt(discriminant) / (2 * a)) Printf("\n Please Enter values of a, b, c of Quadratic Equation : ") Two distinct and real roots exists: 0.81 and -0.31 C Program to Find Roots of a Quadratic Equation using switch caseįloat root1, root2, imaginary, discriminant The output of the above c program as follows: Enter values of a, b, c of quadratic equation (aX^2 + bX + c): 8 -4 -2

Printf("Two distinct complex roots exists: %.2f + i%.2f and %.2f - i%.2f", Imaginary = sqrt(-discriminant) / (2 * a) Printf("Two equal and real roots exists: %.2f and %.2f", root1, root2) Printf("Two distinct and real roots exists: %.2f and %.2f", root1, root2) Root2 = (-b - sqrt(discriminant)) / (2*a) Root1 = (-b + sqrt(discriminant)) / (2*a) Printf("Enter values of a, b, c of quadratic equation (aX^2 + bX + c): ") * C program to find all roots of a quadratic equation End Program C Program to Find Roots of a Quadratic Equation using if else.else if (d = 0) Display “Roots are Equal” and calculate r1 = r2 = (-b / 2*a) … If (d Use the following steps to write a c program to find the roots of a quadratic equation ax2 + bx + c = 0 as follows: C Program to Find Roots of a Quadratic Equation using switch case Algorithm to find roots of a quadratic equation.C Program to Find Roots of a Quadratic Equation using if else.Algorithm to find roots of a quadratic equation.Programs To Find Roots of a Quadratic Equation If the discriminant is less than 0, the roots are complex and different.If the discriminant is equal to 0, the roots are real and equal.If the discriminant is greater than 0, the roots are real and different.The term b 2 - 4ac is known as the discriminant of a quadratic equation. The standard form of a quadratic equation is: ax 2 + bx + c = 0, where

C PROGRAM TO FIND QUADRATIC EQUATION HOW TO
C program to find root of a quadratic equation Through this tutorial, you will learn how to find the root of a quadratic equation in c program.
