Asked

Under what circumstances call by reference is to be preferred over call by value?

Under what circumstances call-by-reference is to be preferred over call-by-value?

1 Answer
Daneel

Call by value and call by reference is related to the C programming language which is a general purpose, imperative computer language. Programming languages generally consists of instructions for a computer. C was originally developed between 1969 and 1973 which is used to re-implement the Unix operating system. On the basis arguments, there are two types of functions that are available in C languages which are with arguments and without arguments. If a function takes any arguments, it must declare variables that accept the values as an argument. These variables are called formal parameters of the function.

Answer Image.

Difference between call by value and call by reference:

Call by value and call by reference are two ways to pass value or data to function in C-language. In call by value, original values cannot be changed or modified while in call by reference, it can be done.

In call by value, any changes made are not reflected in the actual argument while in call by reference; the changes made are reflected in the actual arrangement. Call by value works locally while call by reference works globally.

There is one benefit of call by reference over call by value is in using pointers.therefore not doubling the memory which is used by the variables as in call by value.


Feeds
Feeds
Related Questions
Top Writers