Question: 1. You are given the following C-like code. int x; void f() { int x = 10; h(); } void g() { int x
1. You are given the following C-like code. int x; void f() { int x = 10; h(); } void g() { int x = 100; h(); } void h() { } printf("%d ", x); int main() { x = 1; } f(); g(); (a) (6%) What is the program output if static scoping is used in the above code? (b) (6%) What is the program output if dynamic scoping is used in the above code? (c) (4%) Practically, dynamic scoping is less popular than static scoping. Nonetheless, can you give one advantage of dynamic scoping over static scoping?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
