Loading....
Coupon Accepted Successfully!

 

Functions and Variables

Passing Parameters to a Function

There are two ways to pass parameters to a function:

  • Pass by Value: mechanism is used when you don’t want to change the value of passed paramters. When parameters are passed by value then functions in C create copies of the passed in variables and do required processing on these copied variables.
  • Pass by Reference : mechanism is used when you want a function to do the changes in passed parameters and reflect those changes back to the calling function. In this case only addresses of the variables are passed to a function so that function can work directly over the addresses.

Call Type       Description

Call by value : This method copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.


Call by pointer : This method copies the address of an argument into the formal parameter. Inside the function, the address is used to access the actual argument used in the call. This means that changes made to the parameter affect the argument.


Call by reference : This method copies the reference of an argument into the formal parameter. Inside the function, the reference is used to access the actual argument used in the call. This means that changes made to the parameter affect the argument.





Test Your Skills Now!
Take a Quiz now
Reviewer Name