COP4020 Spring 2011 Homework Assignment 7 1. Consider the following pseudo-code program: sum : integer // a global variable procedure add(amount : integer) sum := sum + amount procedure p(x : integer, adder : procedure) integer sum sum := x adder(x) // invoke procedure that was passed as argument write_integer(sum) begin // main program sum := 0 p(1, add) end a. Suppose dynamic scoping with shallow binding is used by the interpreter to execute this code. What is the value printed by the program? b. Suppose dynamic scoping with deep binding is used by the interpreter to execute this code. What is the value printed?
This is the end of the preview. Sign up
access the rest of the document.