Dev C++ Quadratic Equation
Apr 28, 2013 It’s filed under C, college and tagged c language, c, dev c, imaginary number, program, quadratic equation. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
I am supposed to write a program that asks for the coefficients a, b, and c of a quadratic equation ax2+bx+c=0. It needs to display to the screen one of the following:
• two distinct real numbers (when b2-4ac > 0),
• two distinct complex numbers (when b2-4ac < 0), or
• one real number (when b2-4ac = 0)
I have worked the following program and it doesn't work when set up this way:
If I change the last statement to 'if else' the program works, but I don't think that would be correct. Please help.
- 3 Contributors
- forum 4 Replies
- 827 Views
- 7 Hours Discussion Span
- commentLatest Postby abhimanipalLatest Post
Dave Sinkula2,398
I am supposed to write a program that asks for the coefficients a, b, and c of a quadratic equation ax2+bx+c=0. It needs to display to the screen one of the following:
• two distinct real numbers (when b2-4ac > 0),
• two distinct complex numbers (when b2-4ac < 0), or
• one real number (when b2-4ac = 0)
I have worked the following program and it doesn't work when set up this way:
If I change the last statement to 'if else' the program works, but I don't think that would be correct. Please help.
It's a syntax error as written, and won't compile, so it can't be run. Why would you think this is more correct?
You're also not declaring a, b, and c. Please post actual code and wrap it in code tags.
Quadratic Equation Solver
It would be less redundant to use a temporary, say
Dev C++ Quadratic Equation Formula
instead of recalculating it several times. It is also cleaner, clearer, and easier to read.