pass Array as parameter in method

void fun(int A[],int n)
{
int i;
for(i=0;i<n;i++)
{
printf("%d",A[i]);
}
}
int main()
{
int A[5]={2,3,4,5,6};
//function call
fun(A,5);
}

Note: we are not passing value of an array to func(). we are actually passing a address of an array.

void fun (int *A , int n)
OR
void fun(int A[],int n)
-> Both are pointer to an array

Raman

Related post

Leave a Reply

Your email address will not be published. Required fields are marked *