The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+7 votes
1.5k views

The results returned by function under value-result and reference parameter passing conventions

  1. Do not differ
  2. Differ in the presence of loops
  3. Differ in all cases
  4. May differ in the presence of exception
asked in Programming by Veteran (59.5k points)
retagged by | 1.5k views

2 Answers

+20 votes
Best answer

D. May differ in the presence of exceptions.

In call by reference, the called function is working with the memory location of the passed variables. So, any update to the variables are immediately effective.

In call by value-result, the called function is working with a copy of the passed variables. On return, the updated values are copied back to the original variables. 

So, during a function execution if an exception happens, in call-by-value-result, the passed variables won't be getting updated values. 

answered by Veteran (357k points)
selected by
+1

Even in case of varaible when it used more number of times 

then also it give diff results as comapred to call by ref 

http://cs.stackexchange.com/questions/6549/call-by-value-result-vs-call-by-reference

so will i count Aliasing as an excpetion?

@arjun sir 

0
No. Aliasing is not exception. But with aliasing how the answer is differing for the two calls? Here, we are considering only the return value.
0
okay ,the answer by call be ref is 7 and with call by value result is 4 .

Here inspite of both x and a are same but they behave diff .

in the answer provided he has given how the ref run and CBV runs !
0
Yes, it can differ for aliased variables - but where is that code given?
+1
code is inside stackexchange link
What is meaning of exception
any example plz??
+2
@Arjun Sir  What is meant by exception .. example please
0 votes
Answer should be B.

Call by value result and call by reference may differ in the presence of aliasing (sending the same parameter more than once).
answered by Active (1.3k points)
Answer:

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

39,828 questions
46,802 answers
140,987 comments
58,943 users