Passing Array to function

Passing Array to function

With the help of Pointer we can pass Array as a argument in Function. Array name is a also a pointer variable that hold the address of zero index number element, so when we pass a array name, then we passing the address of zero index number so we need a pointer variable to hold the address of zero index number.

The Syntax of declaring a function:
Return type function_name(data_type  pointer_variable_name,…..);
Example:
Void printIntArray(int *,int);
#include<stdio.h>
void printArray(int *,int);
int main()
{
    int numbers[5]={7,8,3,6,7};
    printArray(numbers,5);
    return 0;
}
void printArray(int *ptr,int l)
{
    int i;
	printf("\nArray elements Are:  ");
	for(i=1;i<=l;i++)
	{
		printf("\t%d",*ptr);
		ptr++;                 
	}
      
}
CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz