Consider the following pseudocode, assuming nested subroutines and static scope: (a) What does this program print? (b)

Question:

Consider the following pseudocode, assuming nested subroutines and static scope:
procedure main() g: integer procedure Bla : integer) x: integer procedure Aln : integer) g:=n procedure R(m : integer) write integer(x) x/:= 2 -- integer division if x > 1 RIm + 1) else Alm) -- body of B X:= a x a R(1) -- body of main B(3) writeinteger(g)

(a) What does this program print?

(b) Show the frames on the stack when A has just been called. For each frame, show the static and dynamic links.

(c) Explain how A finds g.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: