C program to Swap two numbers using call by Reference.

#include<stdio.h>
void swap(int *x,int*y);
int main ()
{
   int a,b;
   printf("\n Enter a= ");
   scanf("%d",&a);
   printf("\n Enter b= ");
   scanf("%d",&b);
   swap(&a,&b);
   printf("\n After swapping a and b are");
   printf("\n a=%d",a);
   printf("\n b=%d",b);
}
   void swap(int *x,int*y)
    {
      *x=*x+*y;
      *y=*x-*y;
      *x=*x-*y;
    }
     

***Input && Output***




Post a Comment

0 Comments