Passing 1-D Array to Function Element by Element in C Programming

August 1, 2010 No Comments » Hits : 227





Passing 1-D Array to Function Element by Element in C Programming

  • Array Elements are passed to function “One by One“.
  • Parameter Passing Method : Pass by Value
  • Actual Element is never Passed to Function , Instead it’s Carbon Copy is Passed to Function
  • Function Body Cannot Modify Original Value.
  • Example :
#include<stdio.h>

void show(int b[3]);

void main()
{
int arr[3] = {1,2,3};
int i;
for(i=0;i<3;i++)
  show(arr[i]);
}

void show(int x)
{
printf("%d ",x);
}

Incoming search terms: