Swapping Without Using Third Variable

 




#include<stdio.h>  

#include<conio.h>

 int main()    

{    

int a, b;      

printf("Enter Two Numbers:- "); 

scanf("%d%d",&a,&b);

a=a+b;    

b=a-b;   

a=a-b;

printf("\nAfter swap a=%d b=%d",a,b);    

return 0;  

}   



Output:-

Enter Two Numbers:- 2

3

After swap a=3 b=2

Comments

Popular posts from this blog

Check whether the no entered is Palindrome or not

Calculate Factorial of a given no with help of Recursion

Find max. and min. element in the integer array