In this program, You will learn C Program to Swap two numbers using pointer. Swapping of two numbers means exchanging values of two variables with each.
#include<stdio.h>
int main()
{
int *p1,*p2,a,b;
p1=&a;
p2=&b;
printf("\n Enter two number a and b:");
scanf("%d%d",p1,p2);
*p1=*p1+*p2;
*p2=*p1-*p2;
*p1=*p1-*p2;
printf("\n value of a=%d and b=%d",*p1,*p2);
return 0;
}
Enter two number a and b:15 20 value of a=20 and b=15