Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) Show the output of the following program segment (written in C-like syntax) for each of the following parameter-passing mechanism: a) pass by value-result b)

1) Show the output of the following program segment (written in C-like syntax) for each of the following parameter-passing mechanism:

a) pass by value-result

b) pass by value, and

c) pass by reference

int x;

void f(int b) {

print(b);

b = 3;

print(a+b);

}

main() {

a = 8;

f(a);

print(a);

}

2) For the program shown below, draw a picture of the run-time environment, at the point marked "HERE", (i.e. at the point when Q is about to return. Show all temporaries, local variables, parameters, locations reserved for return values, and return addresses, as well as the base pointer, frame pointer(s), and the stack pointer. Use the frame organization illustrated in Lecture 12.2.

i: integer;

procedure Q(a,b:integer)

i: integer;

begin

i:=2;

a:= a + b + i; // HERE

end;

procedure P(c:integer)

x:integer;

begin

if c = 7 then P(i)

else Q(3,c);

end;

main()

begin

i:=4;

P(i+3);

end;

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

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

Students also viewed these Databases questions