In: Computer Science
Determine the output of the following program:
var x;
function bar() {
writeln(x);
}
function foo() {
var x;
x = 3;
bar();
}
function oof() {
var x;
x = 7;
foo();
}
x = 5;
oof();
(a) if the static scoping rule is used? What is the reason?.
(b) if the dynamic scoping rule is used? What is the reason?.