C++ program to swap two numbers without using temp variable

#include<iostream.h>
#include<conio.h>void main()
{
clrscr();
int a,b;
cout<<“Enter value of a:”;
cin>>a;
cout<<“Enter value of b:”;
cin>>b;

a=a+b;
b=a-b;
a=a-b;

cout<<“na=”<<a;
cout<<“nb=”<<b;
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *