Question: Consider the following program written in a C-like syntax. Assume parameters are passed by value and that this code compiles. int a, b, c,
Consider the following program written in a C-like syntax. Assume parameters are passed by value and that this code compiles. int a, b, c, d; // global variables initially 0 void gl (int b; int c) { print ("%d %d %d sd", a, b, c, d); } void g2 (int a; int c) ( gl (a, c); } int g3 (int c; int a) { int b; b = 3; gl (a,b); { int c; int d; d = 4; c = 8; g2 (a,b); } gl (a,b); return b; void main() { int a; int b; a = 4; b = 5; a = g3 (b, c); g3 (b, a); // return value ignored What is the output of the program if static scoping is used? What is the output of the program if dynamic scoping is used? Just give the output. Do not give an execution trace.
Step by Step Solution
3.40 Rating (156 Votes )
There are 3 Steps involved in it
Answer For static scoping Output 0 5 0 0 For dynamic scoping Output 0 3 8 4 Explanatio... View full answer
Get step-by-step solutions from verified subject matter experts
