COMP203 Midterm Exam Information


Syllabus | Schedule | Grading Rubric | Midterm
The midterm exam will be a comprehensive exam on the Logo programming language. The exam will be approximately 8 questions long and will cover some or all of the topics listed below: You can view a draft of the Fall 2011 midterm and some sample solutions online.

You may find it useful to bring graph paper to the exam.

Here is a link to the Fall 2009 Midterm and some Solutions. Some questions will have more than one correct answer.

Sample Exam Questions

  1. Decide whether each statement below is true or false. Briefly justify each answer.

  2. Draw a plumbing diagram for the instruction:

    print product sum 2 3 7

  3. Suppose the following procedures are defined:
    to silly :name
     nonsense first :name
     foolish last :name
    end
    
    to nonsense :word
     print sentence :word [had a little lamb.]
    end
    
    to foolish :word
     print sentence :word [is the loneliest number.]
    end
    
    What is the result of entering the instruction:

    silly [Heidi Louise Burgiel]

  4. Write a procedure rectangle that takes two inputs -- a length and a width -- and draws a rectangle with the given length and width.
  5. Write a predicate directionp that takes one input and outputs true if the input is one of the letters N, S, E or W and otherwise outputs false.
  6. What is the result of entering the instruction:

    for [i 1 15 2] [print :i]

  7. What is the result of entering the instruction:

    print map "numberp [Heidi Louise Burgiel]

  8. Write a procedure that takes a positive integer n as input and outputs the sum 1² + 2² + 3² + ... + n².
  9. The procedure sumup defined below was supposed to add the numbers from 1 to the input :n. Instead, it gives the error message shown. Why?
    ? to sumup :n
    > if equalp :n 0 [stop]
    > output :n + sumup :n-1
    > end
    sumup defined
    ? sumup 3
    sumup didn't output to + in sumup
    [output :n + sumup :n-1]