Question: Following PASCAL-like codes are given. In the main program, what is the output value? It is assumed that static scoping rules apply to programs program

Following PASCAL-like codes are given. In the main program, what is the output value? It is assumed that static scoping rules apply to programs

program Main(....);

var P1: integer; var P2: integer; var P3: Integer;

procedure foo(P1: integer, P2: integer)

begin

P1 := P1 + 1; P3 = 5; write (In foo : ", P1, P2, P3);

end;

begin

P1 = 4 ; P2 := 2; foo(P2, P1); write("In main : ", P1, P2, P3);

P3 = 3; foo(P3, P2); write("In main : ", P1, P2, P3);

end.

1. call by value

2. call by refernece

3. call by name

Please describe it in detail.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!