Copyright © – Sudharsan Iyengar and Winona State University
CS – 415 Homework 1: Due: In class, 3/21/23
data[1..10] : integer;
x, y: integer;
procedure f1(pet : array[1..10] of integer)
procedure f11(s : integer)
begin
pet[x] = 12; data[s] = 24;
end
procedure f12(x : integer)
begin
f11(y+x)
end
begin
x = x + y; f12(y);
output pet array; output data array
end
procedure f2(temp : array [1..10] of integer)
procedure f21(p : integer)
begin
x = 2; p = x * p;
end
procedure f22(q : integer)
begin
q = 7;
end
begin
x = 5; f22(x);
temp[x] = x; f21(temp[x]);
output temp array output data array
end
begin
x, y, and all elements of the data array are initialized to 1.
Call f2(data);
Output data array
Call f1(data);
Output data array
end
Show the output when each of the following policies are implemented for the above code:
Pass by Value, Static Scoping.
Pass by Value, Dynamic Scoping.
Pass by Reference, Static Scoping
Pass by Reference, Dynamic Scoping
Pass by Name, Static Scoping
Pass by Name, Dynamic Scoping