Share
In c programming what do you mean by call by value and call by reference ?
In progress
Programming, C
14 Mar 2025
3 views
Answers ( 1 )
In programming, Call by Value and Call by Reference are two different ways of passing arguments to functions.
1. Call by Value
In Call by Value, a copy of the actual parameter is passed to the function. Any changes made to the parameter inside the function do not affect the original value.
Example in C programming:
The function
changeValue()
modifies the value ofx
, but since x is a copy of a, the original a remains unchanged.2. Call by Reference
In Call by Reference, the function receives a reference or address of the actual parameter. Any changes made inside the function directly modify the original variable.
Example
The function
change Value()
takes a pointer to x, which holds the address of a. Modifying*x
changes the actual value of a, as the function operates directly on its memory location.