The Gateway to Computer Science Excellence
+10 votes
2.3k 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
in Programming by Veteran (52.2k points)
retagged by | 2.3k views

2 Answers

+23 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. 

by Veteran (425k 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
+2 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).
by Active (1.5k points)
0
You are right but where is aliasing in the optionπŸ˜…

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
50,644 questions
56,500 answers
195,541 comments
100,994 users