Answer:
The value of x in both scope can be described as follows:
i) Static scope:
x= 5
ii) Dynamic scope:
x=10
Explanation:
The static scoping is also known as an arrangement, which is used in several language, that defines the variable scope like the variable could be labelled inside the source that it is specified.
i) program:
function sub1() //defining function sub1
{
print("x = " + x + ""); //print value
}
function sub2()//defining function sub2
{
var x; //defining variable x
x = 10; //assign value in variable x
sub1(); //caling the function sub1
}
x = 5; //assign the value in variable x
sub2(); //call the function sub2
In Dynamic scoping, this model is don't see, it is a syntactic mode that provides the framework, which is used in several program. It doesn't care how well the code has been written but where it runs.
ii) Program:
var x //defining variable x
function sub1() //defining a function sub1
{
print("x = " + x + ""); //print the value of x
}
x = 10; // assign a value in variable x
sub2(); // call the function sub2
function sub2() //defining function sub2
{
var x; //defining variable x
x = 5; // assign value in x
sub1();//call the function sub1
}