Ask Question
9 May, 14:08

Consider the following pseudocode:

x : integer : = 1

y : integer : = 2

procedure add

x : = x + y

procedure second (P : procedure)

x : integer : = 2

P ()

procedure first

y : integer : = 3

second (add)

first ()

write integer (x)

(a) What does this program print if the language uses static scoping?

(b) What does it print if the language uses dynamic scoping with deep binding?

(c) What does it print if the language uses dynamic scoping with shallow binding?

+4
Answers (1)
  1. 9 May, 15:46
    0
    Part a: The program will print 3.

    Part b: The program will print 4

    Part c: The program will print 1.

    Explanation:

    Part a: As the scoping is static, the x integer has a value of 1 and the y integer has a value of 2 so the addition is 2+1=3.

    Part b: As the scoping is dynamic with deep binding, the x integer has a value of 2 and the y integer has a value of 2 so the addition is 2+2=4.

    Part c: As the scoping is dynamic with shallow binding, the x integer has a value of 1 so it will print 1.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Consider the following pseudocode: x : integer : = 1 y : integer : = 2 procedure add x : = x + y procedure second (P : procedure) x : ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers