C++ Program to swap two numbers without using 3rd variable [DEVCPP/GCC]


//Program to swap two numbers without using 3rd variable

#include<iostream>

using namespace std;

int main()
{
int a,b;

cout<<"ENTER THE VALUE OF A:";
cin>>a;
cout<<"ENTER THE VALUE OF B:";
cin>>b;
cout<<"BEFORE SWAPPING:"<<endl<<"A="<<a<<" "<<"B="<<b<<endl;

a=a+b;
b=a-b;
a=a-b;
cout<<"AFTER SWAPPING:"<<endl<<"A="<<a<<" "<<"B="<<b<<endl;

return 0;
}



Share this

Related Posts

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer

FIND US ON FACEBOOK!