Sunday, November 28, 2010

Write a program to accept two integer numbers and swap those two integer numbers using pointers?

#include
int swap(int *x, int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}
main()
{
int a,b;
printf("Enter any two numbers:");
scanf("%d%d",&a,&b);
printf("Before Swapping ------> %d %d\n",a,b);
swap(&a,&b);
printf("After Swapping -------> %d %d\n",a,b);

}