Question: Consider the following program in an unspecified language: var x = 3 def f ( ) { print ( f: x = +

Consider the following program in an unspecified language:
var x =3
def f(){
print("f: x ="+ x)
g()
h()
print("f: x ="+ x)
}
def g(){
var x =5
print("g: x ="+ x)
h()
}
def h(){
print("h: x ="+ x)
}
f()
What is printed when running this program using (a) static scoping; and (b) dynamic scoping?
Options:
Static scoping: f:3, g:5, h:5, h:3, f:3 Dynamic scoping: f:3, g:5, h:5, h:5, f:3
Static scoping: f:3, g:5, h:5, h:3, f:3 Dynamic scoping: f:3, g:5, h:5, h:3, f:3
Static scoping: f:3, g:5, h:3, h:5, f:3 Dynamic scoping: f:3, g:5, h:3, h:5, f:3
Static scoping: f:3, g:5, h:3, h:3, f:3 Dynamic scoping: f:3, g:5, h:5, h:5, f:5

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Questions!