Spring 2001, CSE 428: Quiz 3.3 - 1 Feb 2001


Please write your Name, Student ID, and Section at the top of the page.

  1. [Pts 2] What does the state represent in an imperative language (only one answer, please)

    1. the associations between identifiers and locations
    2. the associations between locations and values
    3. the result of all the expressions in the program
    4. the result of the type-checking

  2. [Pts 2] What is the result of the evaluation of an assignment x := e (only one answer, please)

    1. it changes the value of the expression e
    2. it changes the value in the location associated to x
    3. it checks that the value of x and the value of e are the same
    4. it returns a new environment

  3. [Pts 2] What run-time structures are needed to interpret an imperative language (only one answer, please)

    1. the grammar describing the language
    2. the environment alone
    3. the state and the environment
    4. the result of all previous expressions in the program

  4. [Pts 2] Consider the following command in the mini-imperative language
       begin
         y
         in y := 1;
            begin x in x := y + 2; y := x  end;
            c
       end
    
    What is the value of y at the beginning of the execution of c?
    Note: an equivalent fragment of code in C++ would be:
       int y = 1; { int x; x = y + 2; y = x; } c;
    

    Answer: 3

  5. [Pts 2] Consider the following command in the mini-imperative language
       begin
         y
         in y := 2;
            begin y in y := 1 end;
            c
       end
    
    What is the value of y at the beginning of the execution of c?
    Note: an equivalent fragment of code in C++ would be:
       int y = 2; { int y = 1; } c;
    

    Answer: 2