Consider the following pseudocode snippet For all questions
     Consider the following pseudocode snippet. For all questions, use variable scope starting at declaration.  y:real:=5.1 procedure f(x:real):  return x*y  procedure g(y:real):  return f(y+7)  print(g(3))  a. What is the final output assuming static scoping?  b. List the referencing environments with static scoping for: f, g, and global  c. What is the final output assuming dynamic scoping?  d. List the referencing environments with dynamic scoping for: f called from global, g called from global, f called from g, and global. 
  
  Solution
Hi, Please fin my answer:
y:real := 5.1
 procedure f(x:real):
 return x*y
procedure g(y:real):
 return f(y+7)
 print(g(3))
a)
 50.1
 b)
 g:
 y = 3
 f:
 x = 10
 y= 5.1
global:
 y = 5.1
c)
 30
 d)
 g:
 y = 3
 f:
 x = 10
 y = 3
 global:
 y = 5.1
Static scoping means that y refers to the y declared innermost scope of declaration that has one.
Dynamic scoping means that y refers to the y declared in the most recent frame of the call-stack the has one.

