Correct Option: C
Passing an array element as a parameter is the answer.
Consider this function call
{
....
a[] = {0,1,2,3,4};
i = 0;
fun(a[i]);
print a[0];
}
fun(int x)
{
int i = 1;
x = 8;
}
Output:
- call-by-reference$: 8$
- call-by-name$: 0$
In Call-by-name, each occurrence of the formal parameter is replaced by the actual argument text. So, the function fun will be executed like:
{
int i = 1;
a[i] = 8; //a[1] is changed to 8 and not a[0]
}
A very good read: http://courses.cs.washington.edu/courses/cse341/03wi/imperative/parameters.html