• edited by
1,935 views
2 2 votes

What type of parameter passing mechanism (call-by-value, call-by-reference, call-by-name, or-by-value result) is the following sequence of actions trying to implement for a procedure call $P (A[i])$ where P (i:integer) is a procedure and A is an integer array?

Is the implementation correct? Explain and correct it if necessary. You are supposed to make only small changes

  1. Create a new local variable, say z.
  2. Assign to z the value of A[i].
  3. Execute the body of P using z for A[i]
  4. Set A[i] to z.​

1 Answer

4 4 votes

implement the call by value result parameter passing technique 
as value is first copied
all changes done in local variable
and then again value copied in actual variable

Position:
Show:

Related questions

12 12 votes
1 1 answer
3.5k
3.5k views
go_editor asked Apr 24, 2016
3,521 views
Show the activation records and the display structure just after the procedures called at lines marked $x$ and $y$ have started their execution. Be sure to indicate which...
75 75 votes
9 answers 9 answers
40.6k
40.6k views
Kathleen asked Sep 13, 2014
40,608 views
The access times of the main memory and the Cache memory, in a computer system, are $500$ n sec and $50$ nsec, respectively. It is estimated that $80\%$ of the main memor...
0 0 votes
1 1 answer
2.6k
2.6k views
Kathleen asked Sep 12, 2014
2,567 views
Bit-slice processorscan be cascaded to get any desired word length processorspeed of operation is independent of the word length configureddo not contain anything equival...
3 3 votes
1 answers 1 answer
2.2k
2.2k views
Kathleen asked Oct 9, 2014
2,240 views
Consider the following program in pseudo-Pascal syntax. What is printed by the program if parameter $a$ in procedure $\text{test1}$ is passed ascall-by-reference paramete...