Call by Value
Call by Value
1. Call by value:
In case of call by value method we pass the value of variables inside a function during
invoking it.Here original value of the variables are not altered.All changes are performed
with dummy arguments.
#include<stdio.h>
#include<string.h>
int main()
{int a,b;
scanf("%d%d",&a,&b);
swap(a,b);
printf("\n%d%d",a,b);
return 0;
int z;
z=x;
x=y;
y=z;
printf("\n%d%d",x,y);
2 Call by reference:
In case of call by reference method we pass the address of variables inside a function during
invoking it.Here original value of the variables are altered.
#include<stdio.h>
#include<string.h>
int main()
{int a,b;
scanf("%d%d",&a,&b);
swap(&a,&b);
printf("\n%d%d",a,b);
return 0;
int z;
z=*x;
*x=*y;
*y=z;
printf("\n%d%d",*x,*y);