Swapping by pointer


//Swapping: 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);
// printf("\nAfter swapping values are \n %d%d",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