Consider the following program. program main int x; proc A; int x; proc B; { x:= 3; call C; x := x + 1; print x; } (end B) proc C; int x; { x:= 1; call D; print x; call F; print x; } (end C) { x:= 2; call B; x :=x+1; print x; } (end A) proc D; proc E; int x; { x:= 5; call F; print x; } (end E) { x:= x +1; print x; call E; x := x + 1; print x; } (end D) proc F; { print x; x:=x+2; } (end F) { x:= 1; call A; print x; } (end main) (a) What is the program output assuming static scoping rules are employed? (b) What is the corresponding output when dynamic scoping rules are employed?
Added by Gloria E.
Close
Step 1
(a) For static scoping: Show more…
Show all steps
Your feedback will help us improve your experience
Sri K and 52 other Calculus 3 educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Use the Addition Principle. How many times is the print statement executed? $$\begin{aligned}&\begin{array}{c}\text { for } i=1 \text { to } m \\\text { for } j=1 \text { to } n\end{array}\\&\operatorname{println}(i, j)\end{aligned}$$
Counting Methods and the Pigeonhole Principle
Basic Principles
Consider the following python code. What is the output? def f(x = 50, y = 50): return(x+y, x-y) x, y = f(y = 100, x = 50) print(x, y)
Urvashi A.
Recommended Textbooks
Calculus: Early Transcendentals
Thomas Calculus
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD