Programming in "C‟ | Differentiate between call by value and call by reference methods. (any four points)

Differentiate between call by value and call by reference methods.

Call by value 

1. A copy of actual arguments(value) is passed to respective formal arguments. 

2. Actual arguments will remain safe, they cannot be modified accidentally. 

3. Address of the actual and formal arguments are different.

4. Changes made inside the function are not reflected in other functions.

Call by reference 

1. Address of actual arguments is passed to formal arguments.

2. Alteration to actual arguments is possible within from called function; therefore the code must handle arguments carefully else you get unexpected results.

3. Address of the actual and formal arguments are the same.

4. Changes made in the function are reflected outside also. 

Post a Comment

0 Comments