12,551,901 members (51,776 online)
Rate this:
See more:
Write the algorithm using a flow chart and the algorithm description for calculating the root of a quadratic equation.

Thanks for your ideas!
Posted 13-Sep-12 0:40am
Updated 13-Sep-12 0:55am
v2
@amitgajjar 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__ 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:

## Solution 2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 Suvendu Shekhar Giri 120 Harpreet05Kaur 40 OriginalGriff 35 Mehdi Gholam 35 ppolymorphe 35
 OriginalGriff 3,926 Suvendu Shekhar Giri 1,863 John Simmons / outlaw programmer 1,687 ppolymorphe 1,581 Karthik Bangalore 1,210

Advertise | Privacy | Mobile
Web02 | 2.8.161021.1 | Last Updated 13 Sep 2012