Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions