Swapping of Two Values (By Ref.)

Program 5: Swapping of Two Values (Call by Reference)


#include<stdio.h>
#include<conio.h>
void main()
{
 int a,b;
 printf("Enter first & second value");
 scanf("%d%d",&a,&b);
 printf("Both values are:\n %d%d",a,b);
 swapv(&a,&b);
getch();
}

swapv(int *x,int *y)
{
 int t;
 t=*x;
 *x=*y;
 *y=t;
 printf("\nAfter swapping values are \n %d%d",*x,*y);
 return 0;
}

Post a Comment

Previous Post Next Post