Skip to main content

Featured

functions in Python

c++ program to swap two numbers without using third variable

/* Following Programs swaps two integer numbers without using third variable
*/
#include<iostream.h>
void main()
{
int a,b;
cout<<"\nEnter two numbers\n";
cin>>a>>b;
cout<<"\nNumbers before swapping "<<a<<"\t"<<b<<"\n";
a=a+b;
b=a-b;
a=a-b;
cout<<"\nNumbers after swapping "<<a<<"\t"<<b<<"\n";
}

OUTPUT:

Comments

Post a Comment

Popular Posts