var numer, denom : int
var quotient, remainder : int
% ask the user for a numerator & denominator
put "Enter the numerator: " ..
get numer
put "Enter the denominator: " ..
get denom
% exit loop when numerator is less than denominator
loop
exit when (numer < denom)
% check for division by zero - not allowed!
if (denom not= 0) then
% determine quotient and remainder
quotient := numer div denom
remainder := numer mod denom
% output mixed fraction
put numer, "/", denom, " = " ..
put quotient, " and ", remainder, "/", denom
else
put "Division by zero is not allowed!"
end if
% get the next fraction
put "Enter the numerator: " ..
get numer
put "Enter the denominator: " ..
get denom
end loop
Comments (0)
You don't have permission to comment on this page.