Consider the program in pascal with static scope


Question:

Output for values

1. Consider the following program in Pascal with static scope:

program main (input, output);
var i, j, k, m: integer;
procedure Q (var i: integer; m: integer);
begin
i := j + 1;
m := k + 1;
writeln (i, j, k, m);
end
procedure P(var i: integer; j: integer);
var k: integer;
procedure S(i: integer)
begin
i := k + 3;
m := i + 3;
writeln(i, j, k, m);
end
begin
k := 8;
i := i + k;
j := j + k;
Q(i, j);
writeln(i, j, k, m);
S(m);
writeln(i, j, k, m);
end
begin
i := 5;
j := 2;
k := 7;
m := 9;
writeln(i, j, k, m);
P(i, k);
writeln(i, j, k, m);
Q(j, m);
writeln(i, j, k, m);
end
Please fill in the following table with the values of i, j, k, and m for each writeln
statement. Assume use call by value
Place of writeln statement i: J: k: m:
1. In Main, before calling P
2. In Q
3. In P after Q
4. In S
5. IN P after S
6. In Main after P
7. In Q
8. In Main

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Consider the program in pascal with static scope
Reference No:- TGS01937448

Now Priced at $20 (50% Discount)

Recommended (96%)

Rated (4.8/5)