Skip to main content

passing array to a function by declaring array as parameter in function


#include <stdio.h>
int fun1(int array[])
{
for (int i = 0; i < 4; ++i)
{
printf("The value of %d is %d \n",i,array[i]);

}
array[0]=89;/*if we change the formal(parameter) value effect will be reflected in
actual(parameter) value as it passes the address of array*/

}
int main ()
{
int arr[]={2,4,6,8};
printf("The value of index 0 is %d\n",arr[0]);
fun1(arr);
printf("The value of index 0 is %d\n",arr[0]);
return 0;
}

Comments