in Programming retagged by
10 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
in Programming retagged by

Subscribe to GO Classes for GATE CSE 2022

2 Answers

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

selected by


edited 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
why this question contain out of syllabus tag?
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).

1 comment

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