Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started