Consider this program and explain it What does it output Wh
Consider this program and explain it. What does it output ? Why ?
Consider the following program: Assuming that the programming language uses static scoping, what value does this program print? Assuming that this language uses dynamic scoping, what value does this program print?Solution
There is one variable x, two procedures and one main method.
Procedure one() is – setting the value of x as 1.
Procedure two() is – setting the value of x as 2 and calling the procedure one().
Main method () setting the value of x as 0 and calling procedure two().
Static scope: x = 1; \\\\ it will not set the value of x from procedure two().
Dynamic scope: x =2; \\\\ setting the value of x from procedure one().
