We can swap the number without a third variable with the help of pointer with different approaches.

```Description
x=10,  y=20
x=x+y    //Now see here x value updated now with 30
y=x-y     //Now y value is 30-20 is 10
x=x-y     //Now x value is 30-10 is 20```

#### Program

```#include<stdio.h>
#include<conio.h>
void swap ( int *x,int *y ) {
*x = (* x) + ( * y ) ;
*y = (* x) - ( * y ) ;
*x = (* x) - ( * y) ;
}
void main ( ) {
int  x , y ;
clrscr ( ) ;
printf ( “Enter two Number!” ) ;
scanf ( “%d% d ”, &x , &y ) ;
swap ( &x , &y ) ;
printf ( ‘The value of x after swap is %d  n”,x ) ;
printf ( ‘The value of y after swap is %d  n”,y ) ;
}```

Output:
Enter two Number! 10 20
The value of x after swap is 20
The value of y after swap is 10

Comments to: Swap the number without third variable using pointer in C

### New Dark Mode Is Here

Get our monthly recap with the latest news, articles and resources.

Codeverb is simply an all in one interactive learning portal, we regularly add new topics and keep improving the existing ones, if you have any suggestions, questions, bugs issue or any other queries you can simply reach us via the contact page Welcome to Codeverb 