CALL BY VALUE:
CALL BY VALUE:
The changes made in the formal
arguments will not reflect to atual arguments.
/* Example for Call by Value */
void main(){
int a,b;
void swap(int,int);
clrscr();
printf(“\n enter the 2 integers”);
scanf(“%d%d”,&a,&b);
printf(“\n before swapping a=%d \t b=%d”,a,b);
swap(a,b);
printf(“\n after swapping a=%d \t =%d “,a,b);
getch();
}
void swap(int x, int y)
{
int temp;
temp=x;
x=y;
y=temp;
}
Comments
Post a Comment