4. (35 points) Consider the following pseudocode which uses dynamic scoping. What does the program print if the language uses shallow binding? What does it print with deep binding? x: integer // global procedure print_x write_integer (x) procedure first x := x * 3 procedure second (F: procedure) x: integer x := 5 F() print_x() x := 7 second(first) print_x()
Added by Erica D.
Close
Step 1
If the language uses shallow binding, the program will print: - 15 (result of x*3 in procedure first) - 5 (value of x in procedure second) - 15 (result of x*3 in procedure first, which was called by second) - 15 (global value of x) Show more…
Show all steps
Your feedback will help us improve your experience
Farruh Turgunov and 97 other AP CS 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
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.
What is the output of the following code? [10] int x; int *p; int *q; p = new int[10]; q = p; *p = 4; for (int j = 0; j < 10; j++) { x = *p; p++; *p = x + j; } for (int k = 0; k < 10; k++) { cout << *q << " "; q++; } cout << endl
Ravindra Y.
What is the output of the following program? 10 Let $\mathrm{Sum}=0$ 20 Let $\mathrm{N}=8$ 30 if $\mathrm{N}<1$ then Go to 70 40 Let Sum $=$ Sum $+\mathrm{N} * \mathrm{~N}$ 50 Let $\mathrm{N}=\mathrm{N}-2$ 60 Go to 30 70 Print Sum 80 end (1) 120 (2) 125 (3) 145 (4) 170
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD