# Write a program to find roots of quadratic equation in c

After this much reading let us finally code the solution of this program. Find discriminant of given equation using formula i. You can also use pow function to find square of b.

Compute the roots based on the nature of discriminant. It is recommended to learn this program using another approach using switch If discriminant is zero.

For the above nested switch there are two possible cases. Input coefficients of quadratic equation. If discriminant is positive. Wikipedia states, in elementary algebra a quadratic equation is an equation in the form of Solving quadratic equation A quadratic equation can have either one or two distinct real or complex roots depending upon nature of discriminant of the equation.

Where discriminant of the quadratic equation is given by Depending upon the nature of the discriminant, formula for finding roots can be given as: Program to find roots of quadratic equation using switch For case 0 means discriminant is either negative or zero. Where discriminant of the quadratic equation is given by Depending upon the nature of the discriminant, formula for finding roots is be given as.

Logic to find roots of quadratic equation using switch Then there are two real distinct roots given by. There exist one more condition to check i. Compute roots based on the nature of discriminant. Whereas case 0 means discriminant is zero.

For case 1 means discriminant is positive. Then there are two real distinct roots given by. Which is case 1 and case 0. Store it in some variable say a, b and c. In elementary algebra quadratic equation is an equation in the form of Solving quadratic equation A quadratic equation can have either one or two distinct real or complex roots depending upon nature of discriminant of the equation.

Then it will have two distinct complex roots given by. If discriminant is zero then, it has exactly one real root given by. If discriminant is negative then, it has two distinct complex roots given by.

Store it in some variable say a, b and c. Input coefficients of quadratic equation from user. Logic to find all roots of a quadratic equation Based on the above formula let us write step by step descriptive logic to find roots of a quadratic equation.

Then it have exactly one real root given by. If discriminant is positive. If discriminant is negative. Learn more - Program to find roots of quadratic equation using switch case.

Apply the formula to compute roots for both the inner cases.and if discriminant. Java Program to find Roots of a Quadratic Equation using Else If This program allows user to enter three values for a, b, and c. Next, this program will find roots of a quadratic equation using Else If Statement.

Write a C program to find all roots of Quadratic equation using switch case. Logic to find all roots of quadratic equation using switch case in C program. Learn C programming, Data Structures tutorials, exercises, examples, programs, hacks, tips and tricks online.

This C Program calculates the roots of a quadratic equation. First it finds discriminant using the formula: disc = b * b – 4 * a * c. There are 3 types of roots.

Enter quadratic equation in the format ax^2+bx+c: 2x^2+4x+-1 Roots of quadratic equation are:Other Related Programs in c C Program to calculate the Combinations and Permutations.

For a quadratic equation ax 2 +bx+c = 0 (where a, b and c are coefficients), it's roots is given by following the formula. The term b ac is known as the discriminant of a quadratic equation. The discriminant tells the nature of the roots. If discriminant is greater than 0, the roots are real and different.

Write a program to find roots of quadratic equation in c
Rated 4/5 based on 73 review