Pass by reference (OR) Call by Reference : In pass by reference, a function is called with addresses of actual parameters. In the function header, the formal parameters receive the addresses of actual parameters. Now the formal parameters do not contain values, instead they contain addresses. Any variable if it contains an address, it is called a pointer variable. Using pointer variables, the values of the actual parameters can be changed. This way of passing parameters is called call by reference or pass by reference.
Ex : #include<stdio.h>
#include<conio.h>
void swap(int a,int j);
void main()
{
int i,j;
printf("Enter i and j values:");
scanf("%d%d",&i,&j);
printf("Before swapping:%d%d\n",i,j);
swap(&i ,&j);
printf("After swapping:%d%d\n",i,j);
}
void swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}