% Solves ax^2 + bx + c = 0

a= input('Enter a: '); 
b= input('Enter b: '); 
c= input('Enter c: ');
d= b^2 -4*a*c;
if (d >= 0)
   r1= (-b-sqrt(d))/(2*a);
   r2= (-b+sqrt(d))/(2*a);
   fprintf('Root 1 = %10.6f \n',r1)
   fprintf('Root 2 = %10.6f \n',r2)
else
   realPart= -b/(2*a);
   imagPart= sqrt(-d)/(2*a);
   fprintf('Root 1 = %10.6f + i * %10.6f \n',realPart,imagPart)
   fprintf('Root 2 = %10.6f - i * %10.6f \n',realPart,imagPart)
end
    