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.
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?
|