Exam2_Question3

Exam2_Question3 - x1 = (-b + sqrt(b^2-4*a*c)) / (2*a); x2 =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
clear, clc a = input('Please input the value of variable a: '); b = input('Please input the value of variable b: '); c = input('Please input the value of variable c: '); c discrim = (b^2) - (4*a*c); d if(discrim > 0) disp('The equation has two roots: ');
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x1 = (-b + sqrt(b^2-4*a*c)) / (2*a); x2 = (-b - sqrt(b^2-4*a*c)) / (2*a); disp(x1, x2); elseif(discrim==0) disp('The equation has one root: '); x1 = -c/b; disp(x1); elseif(discrim<0) disp('The equation has no real roots.'); end...
View Full Document

Ask a homework question - tutors are online