Dev C++ Quadratic Equation

Jan 26, 2013  Write a C program to Solve Quadratic equation Quadratic equation Write a program that calculates the real solution of the quadratic equation ax²+bx+c=0 Read in the values for the p. C code to print all odd and even numbers in given range. Hi, I am trying to make a variable equation solver using DEV-C. I just need to know how to get C to solve an equation inputed by the user. So you input something like 1+1 and i need it to solve the problem and output the answer. Heres an example.

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.

Edited by WaltP: Added CODE tags -- with all the help about them, how could you miss using them????
  • 3 Contributors
  • forum 4 Replies
  • 827 Views
  • 7 Hours Discussion Span
  • commentLatest Postby abhimanipalLatest Post

Dave Sinkula2,398

Equation

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?

Dev C++ Quadratic Equation Formula

You're also not declaring a, b, and c. Please post actual code and wrap it in code tags.

Dev C Quadratic Equation On Program

Dev C++ Quadratic Equation

Dev C++ Quadratic Equation Calculator

It would be less redundant to use a temporary, say

Dev C++ Quadratic Equations

instead of recalculating it several times. It is also cleaner, clearer, and easier to read.