The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+6 votes

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 (68.9k points)
retagged by | 1.1k views

1 Answer

+18 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 (332k points)
selected by

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

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

so will i count Aliasing as an excpetion?

@arjun sir 

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.
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 !
Yes, it can differ for aliased variables - but where is that code given?
code is inside stackexchange link
What is meaning of exception
any example plz??
@Arjun Sir  What is meant by exception .. example please

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

32,693 questions
39,293 answers
36,701 users