Example 10: Solve the Quadratic Equation

Learn how to solve quadratic equations using the IF conditions.

Problem

A quadratic equation is an equation of this form:

ax2+bx+c=0ax^{2}+bx+c=0

Given the values of the coefficients a, b, and c, you need to find the corresponding quadratic equation solution.

The following output needs to be printed on the console:

  • Roots (if any)
  • No real roots (if no roots)

Example

Input (a, b, c) Output
1, 5, 6 -2.000000 , -3.000000
1, 2, 3 No real roots

Try it yourself

Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.

Get hands-on with 1400+ tech skills courses.