CALL BY REFERENCE

·

In CALL BY REFERENCE the addresses of actual arguments in the calling function are copied in to formal arguments of the called function. This means that using these addresses we would have an access to the actual arguments and hence we would be able to manipulate them the following program illustrates this.

main ( )
{
int a = 10, b =20, swapr (&a, &b);
printf (“\n a = %d b= %d”, a, b);
}
swapr (int *x, int * y)
{
int t;
t = *x
*x = *y;
*y = t;
}

The output of the above program would be
a = 20 b =10

About Me

Blog Archive