Skip to content

Instantly share code, notes, and snippets.

@OwiseKyawMinOo
Created March 10, 2018 16:59
Show Gist options
  • Save OwiseKyawMinOo/9560d07ee733746e0484655997b4c199 to your computer and use it in GitHub Desktop.
Save OwiseKyawMinOo/9560d07ee733746e0484655997b4c199 to your computer and use it in GitHub Desktop.
% 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