Assuming the language supports these evaluation strategies, what would be the result for call by reference, call by name, and call by value?
void swap(int a; int b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int i = 3;
int A[5];
A[3] = 4;
swap (i, A[3]);
call by value
-The changes done inside swap method are not visible after calling the method.
ie. after
swap (i, A[3]);i, A[3]values don’t get changed.call by ref:
The changes done inside swap method are visible after calling the method.
ie. after
swap (i, A[3]);i, A[3]values get exchanged.if you are using C++ as language then the signature of the method should be changed to reflect the pass by reference: