YCP Logo Problem Set 4

Due: Monday, Nov 10th by 11:59 PM

Part I

Do the following exercises from the textbook (Watt, Programming Language Design Concepts):

  • Chapter 2: 2.4.1, 2.5.5

Part II

Consider the following C program:

#include <stdio.h>

int sumDigits(int n) {
        if (n < 10) {
                return n;
        } else {
                return (n % 10) + sumDigits(n / 100);

int main(void) {
        int x = 90125;
        int result = sumDigits(x);
        // (HERE)
        printf("%i\n", result);
        return 0;

(1) Show the stack of activation records in the program at the point where the maximum number of simultaneous activation records exist when the program runs.

(2) List all bindings in the environment at the point labeled (HERE). For each binding, list the identifier, type, and entity to which the identifier is bound.

Part III

Consider the following program written in a C-like programmign language:

int f(int x) {
        x = 42;

int main(void) {
        int q = 17;
        printf("%i\n", q);

(3) If the program prints 17, what is the default parameter-passing mechanism?

(4) If the program prints 42, what is the default parameter passing mechanism?

Submitting your work

Save your answers in a text document (plain text, PDF, OpenOffice, or MS Word formats), and upload to the Marmoset server as hw4.

The Marmoset server is available using the URL: