Using if and then statements

11 views (last 30 days)
lucas erickson
lucas erickson on 17 Sep 2015
Edited: Rick Rosson on 17 Sep 2015
Write a MATLAB program to compute both roots of the quadratic equation as you input the values of a, b, and c. &nbsp Requirements:
a) Use “input” to ask the user to put in the values of a, b and c
b) Use “if” structure to avoid division by zero and complex roots
c) Print out the roots for the following situations:
(1). a=2, b=10, c=12
(2). a=0, b=10, c=4
(3). a=4, b=10, c=100
  1 Comment
Stephen23 on 17 Sep 2015
Do you actually have a question, or do you just want us to do your homework for you?

Sign in to comment.

Answers (1)

Rick Rosson
Rick Rosson on 17 Sep 2015
Edited: Rick Rosson on 17 Sep 2015
function r = findQuadraticRoots(a,b,c)
if something is true
do some stuff;
do some other stuff;


Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by