BCA / B.Tech 8 min read

Call by Value & Call by Reference

Call by Value & Call by Reference in C:


In the C language, when we call a function, two main methods can be used: Call by Value and Call by Reference. These two methods determine how parameters are passed to a function.

Call by Value:
In this method, only the value of the variable is passed to the function, not the actual memory address of the variable. This means that a copy of the variable's value is made inside the function. Any changes made to the variable inside the function do not affect the original variable's value.
Advantages: Simplicity, data safety, and less chance of conflicts.
Disadvantages: Higher memory consumption and not effective when the original value needs to be changed.

Call by Reference:
In this method, the actual memory address of the variable is passed to the function, not just its value. This means that the original value of the variable can be changed inside the function. This method does not require creating a copy of the variable.
Advantages: Ability to change the original data, memory savings, and effectiveness when modification is needed.
Disadvantages: Complexity, reduced data safety, and risk of unexpected changes.

A comparison table is included to highlight the key differences between the two methods.