CALL BY ADDRESS/REFERENCE EXAMPLE 1:
void swap(int*a,int *b)
{
int t;
t=*a;
*a=*b;
*b=t;
}
void main()
{
int a=10,b=20;
printf("Before swapping : %d,%d\n",a,b);
swap(&a,&b);
printf("After
swapping : %d,%d\n",a,b);
}
OUTPUT
Before swapping 10,20
After swapping 20,10
No comments:
Post a Comment