| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Exercise 14_3 Solution

Page history last edited by Steve Sweeney 15 years ago

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.