Give a program which has a different result when interpreted using dynamic scoping from that using static scoping

It is desired to obtain an unambiguous context-free grammar G0
April 1, 2023
Sketch parsers based on (a) recursive descent
April 1, 2023

Give a program which has a different result when interpreted using dynamic scoping from that using static scoping

Compiler Construction
Give short answers for each of the following.
(a) Give a program which has a different result when interpreted using dynamic
scoping from that using static scoping.
(b) Give a program (using let to declare variables) which runs with no run-time
type errors under dynamic typing but is invalid in a static typing regime such
as that of Java or C.
(c) Compared with int v[8], why might the declaration int v[e] cause less
efficient code to be compiled if e is not a constant expression, or even if e is a
large constant?
(d) Give two context-free grammars which accept the same strings with one being
ambiguous and one non-ambiguous.
(e) Give a data-structure type declaration in a language of your choice which might
be useful to represent parse trees for the following grammar:
E -> E + T | E – T | T
T -> P ^ T | P
P -> ( E ) | n
Here E is the start symbol and n is a terminal symbol representing the result
of lexing an integer constant.
[4 marks each]