Question: For the program below show the output. (for space you can place the four values printed by P1 on the same line. Assume static scoping

For the program below show the output. (for space you can place the four values printed by P1 on the same line.

Assume static scoping

PROGRAM EX1; int i; // global

int A[3]; // global - array starts at 1

PROCEDURE P1( int x, int y)

Begin

y := 2;

PRINT(x); // <- this is where something is OUTPUT

i := 3; PRINT(x); // <- this is where something is OUTPUT

i := 3; PRINT(x); // <- this is where something is OUTPUT

PRINT(y) // <- this is where something is OUTPUT

END;

BEGIN //main

A[1]:= 7; A[2]:= 13; A[3]:= 11;

i := 1;

P1(A[i], i); // first call

P1(i, A[i]); // second call

END.

a) x is passed by value and y is passed by value. _____________________________________

b) x is passed by value and y is passed by name. _____________________________________

c) x is passed by name and y is passed by value. _____________________________________

d) x is passed by name and y is passed by name. _____________________________________

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!