Arguments are the variables, inside the parentheses, after the function name which is used to pass informations to functions. Beside passing variables and pointers, arrays can also be passed as a function parameter or argument.
Syntax:
Return_type functionName (Data_type array Name[])
{
code to be executed;
}
Example:
#include<stdio.h> int maximum(int a[],int size) { int max = a[0]; int i=0; for(i=1;i<size;i++) { if(max < a[i]) max = a[i]; } return max; } void main() { int i=0,max=0; int array[] ={9,52,77,635,889,679,6,54,78,34}; printf ("List of Numbers:\n"); for(i=0;i<10;i++) { printf ("%d",array[i]); printf ("\n"); } max = maximum(array,10); printf("\nLargest Number is: %d",max); } |
Output
List of Numbers: 9 52 77 635 889 679 6 54 78 34 Largest Number is: 889 |