Question: Consider the following pseudocode: What does this programprint if the language uses static scoping? What does it print with dynamic scoping? Why? x: integer --

Consider the following pseudocode:
x: integer -- global procedure set xln : integer) x:= n procedure print.x() write.integer(x) procedure firstl) setx(1) print xl) procedure second() x : integer setx(2) print x() setx(0) first() print.x() second() print.x()What does this programprint if the language uses static scoping? What does it print with dynamic scoping? Why?

x: integer -- global procedure set xln : integer) x:= n procedure print.x() write.integer(x) procedure firstl) setx(1) print xl) procedure second() x : integer setx(2) print x() setx(0) first() print.x() second() print.x()

Step by Step Solution

3.37 Rating (166 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

With static scoping it prints 1 1 2 2 ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Language Pragmatics Questions!