Rate this:
See more:
Write the algorithm using a flow chart and the algorithm description for calculating the root of a quadratic equation.

Posted 13-Sep-12 1:40am
Edited 13-Sep-12 1:55am
v2
@amitgajjar at 13-Sep-12 6:45am

What you have done so far ?

Rate this:

## Solution 3

What you have tried so far.? This seems like school or university assignment, assume that your teacher or lecturer is also reading these forums.

You should try something by your side first and then post question if you get stuck somewhere. You MUST try here[^] first.

Also refer How to ask a good question?[^]
Rate this:

## Solution 4

Starting with:

ax2 + bx + c = 0

the two possible roots are given by

x1 = (-b + (b2 - 4ac)0.5) / 2a

x2 = (-b - (b2 - 4ac)0.5) / 2a

Depending on the domain in which the solution can lie, you might have to check the discriminant for being smaller than 0. The discriminant is the part inside the square root: b2 - 4ac.
If the domain of the solution are the real numbers R then the discriminant being less than zero will mean that there is no solution. Should the domain be in the set of complex numbers C a solution will exist even if the discriminant is less than zero:

x1 = -b/2a + J(|b2 - 4ac|)0.5/2a
x2 = -b/2a - J(|b2 - 4ac|)0.5/2a

Solutions of quadratic equations are always complex conjugates of each other when the discriminant is smaller than zero.

Should the discriminant be zero x1 = x2 = -b / 2a there is only one solution.

Now all that is left to do is input the coefficients a,b,c and do the calculations.
I don't think you'll find that too hard to do. Just give it a try!

Regards,

— Manfred
v4
__TR__ at 13-Sep-12 7:34am

My 5 for the explanation and for adding "Thanks for your ideas!" to the OP's question :)
Rate this:

## Solution 1

If you know how to solve it manually (you know that, right?) then you have the algorithm.
Rate this: