What are the values if different types of scoping are used in this program ? Con
ID: 3941292 • Letter: W
Question
What are the values if different types of scoping are used in this program ?
Consider the following pseudo-code program: sum: integer//a global variable procedure add(amount: integer) sum:= sum + amount procedure p(x: integer, adder: procedure) integer sum sum: = x adder(x)//invoke procedure that was passed as argument write_integer(sum) begin//main program sum: = 0 P(1, add) end Suppose dynamic scoping with shallow binding is used by the interpreter to execute this code. What is the value printed by the program? Suppose dynamic scoping with deep binding is used by the interpreter to execute this code. What is the value printed? Suppose static scoping is used. What is the value printed by the program?Explanation / Answer
Question a : Suppose dynamic scoping with shallow binding is used by the interpreter to execute this code. What is the value printed by the program?
output:: 1
question b:suppose dynamic scoping with deep binding is used by the interpreter to execute this code. What is the value printed?
output:: 1
question c: suppose static scoping is used. What is the value printed by the program?
output:: 2
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.