C++ program to swap two numbers without using a 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 Comment

error: Alert: Content is protected!!