How to solve quadratic equation?

3 Ansichten (letzte 30 Tage)
Danny Maefengea
Danny Maefengea am 13 Jun. 2020
Bearbeitet: Ameer Hamza am 15 Jun. 2020
I need help with this question fellas.
Write a function called “QuadRoot”that takes user input for a quadratic function (ax^2+bx+c), a, b and c
and calculates the roots of the function.
Note: if the function does not have any real root, show a message indicating that there
is no real root.
  2 Kommentare
Ameer Hamza
Ameer Hamza am 13 Jun. 2020
This seems like a homework question. What have you already tried?
Danny Maefengea
Danny Maefengea am 13 Jun. 2020
Here's what I've done.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 13 Jun. 2020
Bearbeitet: Ameer Hamza am 15 Jun. 2020
in your code you wrote
d = sqrt(b*b-4*a*c);
and then check if d > 0. This is not the correct condition. You need to check if
d = b*b-4*a*c;
if d > 0
to check if the root is real or not.

Weitere Antworten (0)

Kategorien

Mehr zu Magnetic Elements finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by