The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+1 vote

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

asked in Programming by Veteran (52.1k points) | 355 views

1 Answer

+2 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

answered by (231 points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,811 questions
54,540 answers
75,596 users