Quadratic Equation

This is a discussion on Quadratic Equation within the C Programming forums, part of the General Programming Boards category; So, For our first lab in computer science we need to come up with a program that solves ALL values ...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    101

    Quadratic Equation

    So,
    For our first lab in computer science we need to come up with a program that solves ALL values inputted into the quadratic equation. (imaginary, infinite etc). I have been gone for most classes thus far due to sports... and am really behind. Can anyone satisfy this and then explain it? I'mreally lost. this is wht i have so far
    include <FPT.h>
    int main()
    {
    double a,b,c,x1,x2;
    a=inD() ; b=inD() ; c=inD();
    if (a==0 && b==0 && c==0)
    {
    outS ("There are infinite solutions");
    else {

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by Lucid15 View Post
    Can anyone satisfy this and then explain it?
    Had you read the homework policy, you would know the answer is no.

    Assuming inD and outS are defined in your fpt.h thing, then so far so good. No reason to stop now!

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    101
    I just dont get the concept of what i need to do really. That is all.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Well, do the next bit. How do you know if the answers are imaginary/complex?

  5. #5
    Registered User
    Join Date
    Sep 2008
    Posts
    101
    if the number within the sqrt is , right? we need to solve for real, imiginary/complex, infinite, and none i believe.

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    is ... what? But assuming you've filled in the blank correctly, then yes. So check for that.

    Then you can check for none.

    And then what's left over must be "normal".

  7. #7
    Registered User
    Join Date
    Sep 2008
    Posts
    101
    Sorry i meant to put a 0. After i add all of the exceptions then i ask it to solve the equation at the very end right?

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Not 0, but negative.

  9. #9
    Registered User
    Join Date
    Sep 2008
    Posts
    101

    lost

    I dont know why but im soo lost.... I have no idea where to go next. and how the program shold work.

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    > I have been gone for most classes thus far due to sports
    Decide which you want to do.

    Unless you're naturally gifted in something that you can just do it with minimal instruction, both endeavours pretty much demand full attention. You simply can't coast your way through programming.

    Get all the back lectures, and do all the back exercises and you might begin to catch up.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  11. #11
    Registered User
    Join Date
    Sep 2008
    Posts
    101

    ok

    So i talked to the professor briefly today....
    I guess what i really do not understand is where i need to add these "exceptions" in which the quadratic equation can not be solved. for example on the board he wrote...
    Code:
    double a,b,c,x;
    a=inD();b=inD();c=inD();
    if(a==0) {if (b==0){_______}else{x=-c/b;outD(x);}}
    else{x=(-b+sqrt(b*b-4*a*c))/(2*a);
    outD(x);
    }

  12. #12
    Registered User
    Join Date
    Sep 2008
    Posts
    101
    and i just found out that i will not be missing anymore classes... which is definitely a plus.

  13. #13
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Well work through the equation and find the parts that would require special handling. And use more whitespace, it helps.

  14. #14
    Registered User
    Join Date
    Sep 2008
    Posts
    101
    yes, and two roots right?

  15. #15
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Example:
    Code:
    #include <complex.h>
    I would post more code... but I think that is a start.. Its not how I would do it if it were my homework, but maybe you will find that of some use.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. quadratic equation
    By nynicue in forum C Programming
    Replies: 5
    Last Post: 12-26-2008, 04:57 PM
  2. quadratic equation cpp program problems
    By faluiretoread in forum C++ Programming
    Replies: 2
    Last Post: 11-09-2008, 02:22 PM
  3. Replies: 8
    Last Post: 03-10-2008, 07:15 PM
  4. Quadratic Equation problems
    By Rachel228 in forum C++ Programming
    Replies: 2
    Last Post: 03-15-2006, 01:42 AM
  5. Quadratic Equation Program
    By Ambizzy in forum C Programming
    Replies: 4
    Last Post: 02-19-2002, 08:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21