Question: What does the function test print if the language uses static scoping? What does it print with dynamic scoping? (otherwise assume C++ syntax and
What does the function test print if the language uses static scoping? What does it print with dynamic scoping? (otherwise assume C++ syntax and semantics, e.g. call by value). int n = 1; // global print_plus_n(int x) ( cout < < x + n; } increment_n() { n = n + 2; print_plus_n (n); } test() { int n; n = 200; print_plus_n (7); n = 50; increment_n(); cout < < n; Static Scope Outputs: Dynamic Scope Outputs:
Step by Step Solution
There are 3 Steps involved in it
Lets analyze what happens with both static and dynamic scoping in the given code First lets understand how both static and dynamic scoping works Stati... View full answer
Get step-by-step solutions from verified subject matter experts
