% quad2
% solves ax^2+bx+c = 0
%
a = input ( 'Enter a: ' );
b = input ( 'Enter b: ' );
c = input ( 'Enter c: ' );

d = sqrt ( b^2 - 4 * a * c );

r1 = ( - b - d ) / ( 2 * a )
r2 = ( - b + d ) / ( 2 * a )
%
%  Using fprintf, we can print results in
%  'f': floating point format, or
%  'e': exponential format, or
%  'g': let MATLAB choose the format.
%
disp ( '' )
fprintf ( '  Root #1 = %f\n', r1 );
fprintf ( '  Root #2 = %e\n', r2 );

disp ( '' )
fprintf ( '  Root #1 = %10.6f\n', r1 );
fprintf ( '  Root #2 = %20.16e\n', r2 );

disp ( '' )
fprintf ( '  Root #1 = %g\n', r1 );
fprintf ( '  Root #2 = %20.16g\n', r2 );

