Created
March 10, 2018 16:59
-
-
Save OwiseKyawMinOo/9560d07ee733746e0484655997b4c199 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Project 4 | |
% Owise Kyaw Min Oo | |
a=input('Enter the coeffient of a:'); | |
b=input('Enter the coeffient of b:'); | |
c=input('Enter the coeffient of c:'); | |
dist=(b^2-4*a*c); | |
if dist>0 | |
x1=(-b+(sqrt(dist)))/(2*a); | |
x2=(-b-(sqrt(dist)))/(2*a); | |
fprintf('x1=%f\n,x2=%f\n',x1,x2) | |
elseif dist==0 | |
x=-b/(2*a); | |
fprintf('x1=x2=%f\n',x) | |
else | |
real=-b/(2*a); | |
imag=sqrt(abs(dist))/(2*a); | |
fprintf('x1=%f+%fi\n,x2=%f-%fi\n',real,imag) | |
fprintf('x2=%f-%fi\n',real,imag) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment