Passing Array to Functions
When an array is passed to a function as an argument, the array’s address is actually passed, rather than the values of the elements in the array. If the function modifies the array values, the array will be modified, since there is only one copy of the array in memory.
To pass one dimensional array to the following rules are considered:
1.Function must be called by using only the name of array. It need not include size of array.
For Example: Consider the array list:
Int list[ ]= {0,4,5,-8,17,301};
Let biggest be the called function. To pass the array list and an integer variable to the called function, it can be written as:
Biggest(list,n);
To pass array alone to the called function, it can be written as:
Biggest(list);
2.The function header must have the data type of the array. Size of array need not be specified. However empty square brackets must be used, to specify the parameter as an array. Function definition can have formal parameters.
For Example: the function header for the called function biggest can be written as: int biggest(int array[], int size)
3.Function prototype must specify the argument is an array.
For Example: int biggest(int array[], int size);
The difference between function header and function prototype is only semicolon(;).
LINKS
Array | Types of Arrays | Declaration of Array | Initializing Arrays | Difference between an Array and an Ordinary Variable | String | Declaring a string | Initializing a string | Different functions used to Input of Strings Data | Different Functions used to Output of strings data | Pointer | There are number of reasons for using pointers | Difference between An Array and Pointer | Storage Class | In C, there are four types of storage classes as below | Algorithm | Characteristics/Qualities of a good Algorithm | Flow Chart
ALL LINKS HEAR: Click me
IMPORTANT LINKS HEAR:
Array | Types of Arrays | Passing Array to Functions | Declaration of Array | Initializing Arrays | Difference between an Array and an Ordinary VariablelLINKS
Array | Types of Arrays | Declaration of Array | Initializing Arrays | Difference between an Array and an Ordinary Variable | String | Declaring a string | Initializing a string | Different functions used to Input of Strings Data | Different Functions used to Output of strings data | Pointer | There are number of reasons for using pointers | Difference between An Array and Pointer | Storage Class | In C, there are four types of storage classes as below | Algorithm | Characteristics/Qualities of a good Algorithm | Flow Chart
ALL LINKS HEAR: Click me

Install Our App
Free Mock Tests & Daily Updates
No comments