C – Pass Array to Function

Pass Array as a parameter to a function:

  • We can pass array as input parameter to function.
  • By passing array name, the address will be passed as parameter.
  • We collect the address in Called Function by declaring same type array.
void display(int[]);
int main()
{
            int a[5] = {10, 20, 30, 40, 50};
            display(a);
            return 0;
}
void display(int x[]){
            int i;
            printf(“Array is :\n”);
            for(i=0 ; i<5 ; i++){
                        printf(“%d\n”, x[i]);
            }
}
Scroll to Top