# MCS-177, Intro. to Computer Science I, Fall 2008 Homework Assignment 1 Due: Monday, September 8

You are encouraged to discuss the homework with your fellow students. This does not mean that you divide up the problems so that one student solves a problem and then tells the others how to do it. Instead, each of you should attempt the problems on your own, discuss the problems you encounter with others, brainstorm on ideas for solving these problems, and so on. Each of you is expected to write up your homework independently. If you worked closely with other people, say so at the top of your paper.

Each problem is graded on a 10-point scale. Be sure to see the guidelines for writing up homework assignments.
1. Do exercise 1.5 on page 13.
2. Do exercise 1.12 on page 18.
3. Modify the procedure in exercise 1.12 so that it will return 17 if either of its two arguments is even.  If both are odd, this modified procedure should still return their product.
4. Write a Scheme procedure that will find the largest of three integers.  What are some good test values for this procedure?
5. The first-graders I used to work with liked to find the ``middle'' number of two numbers.  For example, the middle number of 3 and 9 is 6,  while the middle number of 1 and 10 is 5.5.
1. Write the Scheme expression to find the middle number of 17 and 5,678,200.
2. Write a Scheme expression, called middle, that finds the middle number of any two numbers.
3. What value does the following procedure compute?  Try to describe this as succinctly as you can.
(define mystery
(lambda (x y z w)
(middle (middle x y)
(middle z w))))
MCS 177 homepage