C passing array to function



Passing Array to Function in C
Array Definition :
Array is collection of elements of similar data types .
Passing array to function :
Array can be passed to function by two ways :

  1. Pass Entire array
  2. Pass Array element by element

Let us discuss both of them one by one :
1 . Pass Entire array

  • Here entire array can be passed as a argument to function .
  • Function gets complete access to the original array .
  • While passing entire array Address of first element is passed to function , any changes made inside function , directly affects the Original value .
  • Function Passing method : Pass by Address

2 . Pass Array element by element
  • Here individual elements are passed to function as argument.
  • Duplicate carbon copy of Original variable is passed to function .
  • So any changes made inside function does not affects the original value.
  • Function doesn’t get complete access to the original array element.
  • Function passing method is Pass by Value