// To swap value
with call by reference |
#include<stdio.h> |
void swap(int *,int *); //Declaration |
void
main() |
{ |
int x,y; |
printf("\nEnter The Value Of X : "); |
scanf("%d",&x); |
printf("\nEnter The Value Of Y : "); |
scanf("%d",&y); |
printf("\nValues Before Calling Swap : "); |
printf("\nX=%d\tY=%d",x,y); |
swap(&x,&y); //Passing address
of variable |
printf("\n********************"); |
printf("\nValues After Calling Swap : "); |
printf("\nX=%d\tY=%d",x,y); |
} |
void swap(int
*a,int *b) //Collecting address |
{ |
int t; |
t=*a; |
*a=*b; |
*b=t; |
} |
|