454,499 Members | 1,751 Online
Need help? Post your question and get tips & solutions from a community of 454,499 IT Pros & Developers. It's quick & easy.

# HELP

 P: n/a How do I write the quadratic equation in C++? Thank You! SonhadorPR Aug 28 '06 #1
7 Replies

 P: n/a

 P: n/a so********@gmail.com wrote: How do I write the quadratic equation in C++? Thank You! SonhadorPR Send me your instructor's email address, and I'll send it directly to him. Aug 28 '06 #3

 P: n/a

 P: n/a Jim Langston wrote:

 P: n/a "Greg" Jim Langston wrote: >

 P: n/a "Jim Langston" In C or C++ langauge terms this is: x = (-b + sqrt( b*b - 4 * a * c ) ) / 2 * a; x = (-b - sqrt( b*b - 4 * a * c ) ) / 2 * a; Don't you need parentheses there, around the "2 * a" part? Division and multiplication have the same precedence, so as written, the above would divide by 2, then multiply by a, instead of dividing by (2 * a), right? -Howard Sep 11 '06 #7

 P: n/a Howard posted: > "Jim Langston" >In C or C++ langauge terms this is:x = (-b + sqrt( b*b - 4 * a * c ) ) / 2 * a;x = (-b - sqrt( b*b - 4 * a * c ) ) / 2 * a; Don't you need parentheses there, around the "2 * a" part? Division and multiplication have the same precedence, so as written, the above would divide by 2, then multiply by a, instead of dividing by (2 * a), right? Yes Howard, you're correct. The formulae should be: (-b + sqrt(b*b - 4*a*c)) / (2*a); (-b - sqrt(b*b - 4*a*c)) / (2*a); -- Frederick Gotham Sep 11 '06 #8

### This discussion thread is closed

Replies have been disabled for this discussion.