Swapping Using Call By Reference

  1. #include<stdio.h>  
  2. #include<conio.h>  
  3. void swap(int*,int*);  
  4. void main(){  
  5. int a,b,c;  
  6. clrscr();  
  7. printf("Enter two values= ");  
  8. scanf("%d %d",&a,&b);  
  9. swap(&a,&b);  
  10. printf("\n\nAfter swapping a= %d b=%d",a,b);  
  11. getch();  
  12. }  
  13. void swap(int *x,int *y){  
  14. int z;  
  15. z=*x;  
  16. *x=*y;  
  17. *y=z;  
  18. }