Call by Reference
In the call by reference method, instead of passing values to the function that is being called, references/pointers to the original variables are passed.
int a=1;
void fun(int*x)
fun(&a);
{
Definition;
}
Note: Any modification which is done to variable ‘a’ will change the outside function.
Example:
void main()
{
int a=10; //a is read as 10
printf(“%d”,a);
fun(a);
printf(“%d”,a); //a is read as 10
}
void fun(int x) //a is read as 10
{
printf(“%d”,x);
x++;
prinf(“%d”,x) //x is read as 11
}
OUTPUT
10 10 11 11