Function Parameters

Arrays as Functions Parameters:

An array can be passed to a function as an argument in a manner similar to passing individual variables.

  • The called function with array as parameters contains minimum two parameters, the array and the size of the
    array.

When we have an array as parameter in the function we need not specify the array size (in square brackets) in the declaration of array parameter. The array-name is followed by empty square brackets.

  • To pass an array to a called function, it is sufficient to list the name of the array, without any subscripts and the size of the array as arguments When arrays are passed as arguments to a function.
  • Remember one main distinction from passing ordinary variables, if a function changes the value of an array elements, the changes will be made to the original array that was passed to the function.
  • When the entire array is passed as an argument the contents of the array is not copied into the formal parameter array, instead information about the main addresses of the array elements are passed to the function


null

Mr. Sandeep Soni

Founder, Trainer & CEO, Deccansoft Software Services.

Sandeep has 21 yrs of experience working in various Microsoft Technologies/Platforms incl. VB6.0, ASP, VC++, VB.NET, C#. He is involved in managing and architecting projects at Deccansoft. He will be your liaison to Deccansoft, for any kind of communication and project updates. He knows what works and what doesn’t, and what practices are most suitable for design and programming with the ultimate goal of producing a quality system.