Answered! Consider the following code: 1 int x, y: 2 void bar(int a) { 3 int k, q: 4 y = 2 * a: 5 a = a+ 1: 6 .. 7 } 8 void foo(int p: int…

Programming languages:

Consider the following code: int x, y; 2 void bar int a t int k, q; a 1 S void foo(int p, int q) float y, k bar(x) 10 11 13 14 void bazo 15 int m, n 16 17 foo(m, n. 18 bar(x), 19 20 Assume execution ofthe code starts with line 14. Aline number trace of this execution is: 15, 16, 17, 8, 9, 10, 2, 3, 4, 5, 6, 7, 11, 13, 18, 2, 3, 4, 5, 6, 7 This program could be executed using either Lexical (static) or Dynamic scoping Describe the differences in variable binding and referencing for these two different executions. (i.e. first describe the Lexica case, then then Dynamic case using line numbers and variables). Be sure to state at what line in the execution Lexical vs. Dynamic scoping makes a difference

Consider the following code: 1 int x, y: 2 void bar(int a) { 3 int k, q: 4 y = 2 * a: 5 a = a+ 1: 6 .. 7 } 8 void foo(int p: int q) 9 float y, k: 10 bar(x): 11 y = 3: 12 .. 13 } 14 void baz() { 15 int m, n: 16 x = 5: m = 3: n = 2: 17 foo(m, n): 18 bar(x): 19 .. 20 } Assume execution of the code starts with line 14. A line number trace of this execution is: 15, 16, 17, 8, 9, 10, 2, 3, 4, 5, 6, 7, 11, 13, 18, 2, 3, 4, 5, 6, 7 This program could be executed using either Lexical (static) or Dynamic scoping. Describe the differences in variable binding and referencing for these two different executions. (i.e. first describe the Lexical case, then then Dynamic case using line numbers and variables). Be sure to state at what line in the execution Lexical vs. Dynamic scoping makes a difference.

Expert Answer

 
Still stressed from student homework?
Get quality assistance from academic writers!