Array and Pointer notes
•The array element can
be passed to a function by calling the function by value, or by reference.
•In call by value, we
pass values of arrays elements to the function.
•In call by reference,
we pass address of array elements to the function.
Call
by value
/*demonstration of
call by value*/
main()
{ int i;
Int marks[]={23,34,45,22,45};
For(i=0;i<=4;i++)
{ display(marks[i]); //call}
}
Display(int
m)//define
{ printf(“%d”,m); }
Call
by reference
/*demonstration of
call by value*/
main()
{ int i;
Int marks[]={23,34,45,22,45};
For(i=0;i<=4;i++)
{
display(&marks[i]);
}
}
Display(int *m)
{ printf(“%d”,*m); }
Comments
Post a Comment