Function Call By Reference In C Language

aimtocode

Call By Reference

In C, all function arguments are passed by value. this means that the called function is given the values of its arguments in temporary variables rather than the original. This means that the supplied variable's name is passed to the function, and not the variable itself.

When a single value is passed to a function via an actual argument, the value of the actual argument is copied into the function. therefor, the value of the corresponding formal argument can be altered within the function, but the value of the actual argument will not change.

Example:



Output:

 10
 2

Example:



Output:

 Before swapping:
 num1 value is 35
 num2 value is 45
 After swapping:
 num1 value is 45
 num2 value is 35
aimtocode