3.5 Parameter passing techniques in C

Parameter passing techniques: -

  • Parameters are the values or variables that are passed to a function when it is called.
  • These parameters allow data to be shared between the calling function (main) and the called function (sub function).
  • There are mainly two types of parameter passing techniques in C:

                    1. Call by Value

                    2. Call by Reference

1)  Call- by-value: -

  • Call by value is a method of passing arguments to a function in which a copy of the actual variable’s value is passed to the function.
  • Any changes made inside the function do not affect the original variable outside the function.

            Example: -



            Output: -


2) Call-by-reference: -

  • Call by address is a method of passing arguments to a function in which the addresses (memory locations) of the actual variables are passed to the function using pointers.
  • This allows the called function to directly modify the original variables from the calling function.

                 Example: -



            Output: -




Popular posts from this blog

operators in c programming

2.4 Arrays in c programming