Passing An Array
An array is a contiguous block of memory whose base address is
stored in the name of the array.To pass an array we pass the
base address of the array i.e. the name which is accepted in a pointer
/*
http://www.ProbCOMP.com
An array is a contiguous block of memory whose base address is
stored in the name of the array.To pass an array we pass the
base address of the array i.e. the name which is accepted in a pointer
*/
#include<stdio.h>
void pass(int array[],int size)
{
for(int i=0;i<size;i++)
printf(" %d ",array[i]);
}
void pass2(int *arr,int size){
for(int i=0;i<size;i++)
printf(" %d ",arr[i]);
}
void main()
{
int arr[10] ={1,2,3,4,5,6,7,8,9,10};
pass(arr,10); /* writing just the name passes the base address of the array i.e the
the address of the 0th element*/
printf("\n");
pass(arr,10);
}
Download Program


