Run-stack and activation record management

Assignment Help Programming Languages
Reference no: EM131276757

Programming Languages

Assignment

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

Assume static scoping
PROGRAM EX1;
int i; // global
int A[3]; // global

PROCEDURE P1( int x, int y)
Begin

END;

y := 2; PRINT(x); i := 3; PRINT(x); i := 3; PRINT(x); PRINT(y)

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.

Q2. For the program below show the output
Assume static scoping
PROGRAM EX2;
int N; int M; // global

PROCEDURE P1(int x, int y, int z) BEGIN

END;

x := 1;
z := x + y;

BEGIN
N := 2; M := 0
P1 (N, N, M)
PRINT (M);
END.

a) What is printed for M if parameters passed by reference?

b) What is printed for M if parameters passed by value-results?

Q3. For the program below show the output
Assume static scoping
PROGRAM EX3;
int k; // global

PROCEDURE P1(int x)
BEGIN
x := 2;
x := x + k;
END;

BEGIN

END.

k := 1; P1(k);
PRINT (k);

a) What is printed for k if pass by value ?

b) What is printed for k if pass by results ?

Q4. Many programming languages allow unrestricted GOTO statements which allow a programmer to use a GOTO to jump to any visible LABEL. Thinking about the run-stack and activation record management,

a) Though looking very efficient in terms of a quick jump to distant code why may it cause some efficiency problems during execution? Explain.

Q5) Show (draw) the runtime-stack with AR(s) for the following. Include static and dynamic link information (dashed arrows) as used in fig. 10.9 Assume the execution is at the ground condition when it becomes true!!!!
PROGRAM EX5;

PROCEDURE P2(int y)
PROCEDURE P1(int x) // P1 is nested in P2 BEGIN
if (x < 0 ) // ground condition
return;
else P1 (x-1);
END;
BEGIN
P1 (y);
END;
// main driver
BEGIN
P2(3) //assume P2 will be first AR on stack!
END.

Reference no: EM131276757

Questions Cloud

What is the utilization of the servers : In a bank, there are six tellers. The arrival rate of customers is 5 per hour, and the mean service time is 18 minutes. What is the utilization (as a percentage) of the servers?
Concepts associated with corporate governance : The following are concepts associated with corporate governance except:
How to react in life threatening situations : A tactical training company that provides self-defense lessons and teaches people how to react in life threatening situations. Security services will be providing security for people during events. Target market: colleges, public places, celebs, busi..
Manufacturers and sellers of defective medical devices : Do you think manufacturers and sellers of defective medical devices should be subject to civil litigation or criminal prosecution or both? Explain your answer. (Health Management class )
Run-stack and activation record management : Though looking very efficient in terms of a quick jump to distant code why may it cause some efficiency problems during execution? Explain - Show (draw) the runtime-stack with AR(s) for the following. Include static and dynamic link information
Identify the companys stakeholders : Key Parties. (1)Who are the principal parties (i.e., the key parties) involved in the case study?List and briefly identify them.(2) For the primary business in the case studyonly, (a) identify the company's stakeholders.
What makes any corporation or business accountable : If Congress did not mandate the valve by law here in the US, what then makes corporations accountable in this area? What makes any corporation or business accountable to the environment in which does it business?
Why you support or oppose adding the proposed equal rights : Write a 200 to 500 word explanation of why you support or oppose adding the proposed Equal Rights Amendment to Constitution. Make sure that you include some discussion of 14th Amendment levels of scrutiny in your explanation.
Does one store seem to be more trend right than the other : Does one store seem to be more "trend-right" than the other? What is the mix of staple, fashion or fad merchandise in each retailer?

Reviews

Write a Review

Programming Languages Questions & Answers

  Function to retrieve each of the private data members

Write a class called "Date" with month, day and year as private members. Have constructor that sets default date to 1st January 2000. Have accessor function which retrieves each of the private data members.

  Create class to store the product name

Choose a fruit or vegetable product that you might commonly find at the farmers market (for example, tomatoes, potatoes, lettuce, apples, cantaloupes, etc). Create a class that stores the product name.

  What graphical element appears on a shortcut icon

Which of the following locations is not a valid place from which to delete a file and send it to the Recycle Bin?

  Display of the error message from a bound textbox

How does the IDataErrorInfo interface triggers the display of the error message from a bound textbox

  Formulate integer programming model for permanent operators

Company wishes to know number of permanent and temporary operators to hire to minimize costs. Formulate an integer programming model for this problem and solve it by using the computer.

  Create program which lists total points scored

Create program which lists total points scored for each of 30 classrooms. Include invalid input check if a proper room number is not entered.

  Write program which translates letter grade into grade

Write a C++ program which translates the letter grade into a number grade. Letter grades are A B C D F, possibly followed by + or -. Their numeric values are 4, 3, 2, 1, and 0.

  Create artefacts to encapsulate the steps needed

How to create your own functions - Create a program named InvestmentCal, which will read and write values from the Terminal - Pass Task 2.4: My Functions

  Program read weight of package of breakfast cereal in ounces

Write a program which will read the weight of package of a breakfast cereal in ounces and output weight in metric tons as well as number of boxes

  Good coding practices with a meaningful coding example

Documentation of good coding practices with a meaningful coding example, Avoid creating unnecessary objects and always prefer to do Lazy Initialization:

  Create new method public to create and return new picture

Create a new method public Picture frame (int frameSize, Color frameColor) this method will create and return a new picture object.

  Create constructor by allotting value to gpa attribute

We have provided the super call, which does some of the work of constructor. Your code must complete constructor by allotting value of g to gpa attribute.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd