Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: All-Topics
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
Edited 13-Sep-12 0:55am
v2
Comments
@amitgajjar at 13-Sep-12 6:45am
   
What you have done so far ?
Rate this: bad
good
Please Sign up or sign in to vote.

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?[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

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
  Permalink  
v4
Comments
__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: bad
good
Please Sign up or sign in to vote.

Solution 1

If you know how to solve it manually (you know that, right?) then you have the algorithm.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

see below link.
^]
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 585
1 mhegazy94 460
2 Ravi Bhavnani 230
3 Kornfeld Eliyahu Peter 185
4 Shemeemsha RA 160
0 Sergey Alexandrovich Kryukov 7,295
1 OriginalGriff 6,841
2 CPallini 5,420
3 George Jonsson 3,654
4 Gihan Liyanage 2,797


Advertise | Privacy | Mobile
Web02 | 2.8.140922.1 | Last Updated 13 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100