2. Aliasing in the context of programming languages refers to (GATE CS 2000)
(a) multiple variables having the same memory location
(b) multiple variables having the same value
(c) multiple variables having the same identifier
(d) multiple uses of the same variable

Answer (a)
Aliasing describes a situation in which a data location in memory can be accessed through different symbolic names in the program.

Answer (b)
Note the order in which parameters are passed. Inside func1(), x will actually refer to y of main(); and y and z will refer to x of main(). The Statement y = y + 4; will result in 14 and statement z = x + y + z will make z = 3 + 14 + 14 = 31 (because y and z point to same variable x of main). Since z refers to x of main(), main will print 31.

a) Do not differ
b) Differ in the presence of loops
c) Differ in all cases
d) May differ in the presence of exceptions

Answer(d)
In call-by-reference evaluation, a function receives an implicit reference to the argument, rather than a copy of its value. This typically means that the function can modify the argument- something that will be seen by its caller. Note that C doesn’t support call by reference but call-by-reference can be implemented using pointers.

Call-by-value-result uses a combination of call-by-value and call-by-reference. Call-by-value-result works by creating local versions of the parameters passed in. However, the values in these local versions are copied back to the original arguments after the end of the procedure.

In case of exceptions, results may differ. Let us see below example in an arbitrary language

int addTwo(a, b)
{
a = a + b;
b = a + b;
return b;
}

If call-by-value-result is used then calling addTwo(x, x) will return 3x (see below for explanation).

a = a + b; will result in a = x + x
b = a + b; will result in b = 2x + x

If call-by-reference is used then addTwo(x, x) will return 4x (see below for explanation).

a = a + b; will result in a = x + x
b = a + b; will result in b = 2x + 2x