Mask-group

Ways to Call a Function



  • There are two ways to call the function in C language:

  1. Call by value

  2. Call by reference

  • Original value is not modified in call by value but it is modified in call by reference.

Call by Value:

  • In call by value,the original value is not modified.

  • In call by value,value being passed to the function is locally stored by the function parameter in stack memory location.

  • If you change the value of the function parameter,it is changed for the current function only.

  • It will not change the value of a variable inside the caller method such as main().

Call by Reference:

  • In call by reference,the original value is modified because we pass reference(address).

  • Here,the address of the value is passed in the function,so actual and formal arguments share the same address space.

  • Hence,value changed inside the function is reflected inside as well as outside the function.