Assignment for next lab:
- Read pp. 214-228
- Turn in a final project draft proposal. (see handout on
final projects)
CS10 Spring 1998
Homework 4
Due Date: Tues, March 24
Assignment Description
Write MacPippin programs to solve the
following three problems:
- Test whether two numbers are equal. You can assume that the two
numbers to test are stored in cells 14 and 15. After your
program has finished running, cell 16 should contain 1 if the
value stored in cell 14 equals the value stored in cell 15, and 0
otherwise.
- Find the maximum of two integers. As above, assume that the two
integers are stored in cells 14 and 15. After your program
has finished running, cell 16 should contain the larger of the two
integers.
- Divide a number in half. Choose a cell which will store the
number to be divided, and another cell which will store the
answer. Suppose, for example, that cell 15 will contain the
number to be divided, and cell 16 will contain the answer. Then
after
your program has finished running, cell 16 should
contain half of the original value of cell 15. To make the
problem a bit easier, you can assume that the the input will
always be a positive even number.
Hint: Suppose that the number to be divided is
stored in cell 15. First
initialize cell 16 to 0. Then repeatedly subtract 1 from the
contents of cell 15 and add 1 to the contents of cell 16.
Keep doing this until the contents of cell
15 equals the contents of cell 16. At this point, cell 16 will
contain exactly half of the original value in cell 15.
When you've finished each problem, save the solution using
"Save" from the "Pips" menu, and hand in a disk with the saved
programs.