Question: 2. (20pt) Consider the following program in a language where variables are automatically initialized with 0 and x, y, z are constants that were defined

2. (20pt) Consider the following program in a language where variables are automatically initialized with 0 and x, y, z are constants that were defined before the program fragment shown. int a; f(n) { a = n; } g() { print a; } h() { f(x); g(); } k() { int a; g(); f(y); } f(z); g(); k(); g(); h(); g(); (1) (16pt) Give the output of the program for (a) static scoping and (b) dynamic scoping. Explain your answer by running the program in each case step by step, including full details concerning variable assignments and output of print statements. (2) (4pt) Find for what values of x,y,z the output of the program is the same with static or dynamic scoping
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
