How to solve quadratic equation?

4 次查看(过去 30 天)
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 个评论
Ameer Hamza
Ameer Hamza 2020-6-13
This seems like a homework question. What have you already tried?

请先登录,再进行评论。

采纳的回答

Ameer Hamza
Ameer Hamza 2020-6-13
编辑:Ameer Hamza 2020-6-15
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Magnetic Elements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by