C Programming
Call by Address
Call by Address
When
we use call by value machanism actually we pass the address of variable. Hence if we change the value of variable in called function will also
effect the original value in calling function. The concept of pointer is used in call by address mechanism.
Ex.
void show(int *,int *);
void main()
{
int a,b;
printf("Enter two no.");
scanf("%d%d",&a,&b);
printf("Before calling:-%d%d",a,b);
show(&a,&b);
printf("After Calling:-%d%d",a,b);
}
void show(int *a, int *b)
{
printf("In called function:-\n");
*a=*a+5;
*b=*b+10;
printf("Modified value=%d%d",*a,*b);
}
Output:-
Enter two no 10 20
Before calling:-10 20
In called function
Modified value=15 30
After calling:-15 30