+ 2

swap two variable a , b

#include<iostream> using namespace std; int main() { int a, b; cout<<"Enter n. to A and B"<<"\n"; cin>>a>>b; cout<<"\n"<<"Before Value"<<"\n"<<"A="<<a<<"\n"<<"B="<<b; a+=b; b=a-b; a-=b; cout<<"\n"<<"After Value"<<"\n"<<"A="<<a<<"\n"<<"B="<<b; return 0; }

12th Jul 2016, 2:17 PM
meherDev
meherDev - avatar
6 Respostas
+ 1
jst edit one line, where you write a=b .. instead of a=b there is b=a... try it... almost all things are correct..
12th Jul 2016, 3:20 PM
siddhpura Amit
siddhpura Amit - avatar
+ 1
a+=b; b=a - b; a-=b;
12th Jul 2016, 3:39 PM
tomorrow's never coming
tomorrow's never coming - avatar
+ 1
okay..
12th Jul 2016, 3:47 PM
meherDev
meherDev - avatar
+ 1
yury d, very nice formula... thanks a lots
12th Jul 2016, 8:55 PM
meherDev
meherDev - avatar
+ 1
np
12th Jul 2016, 8:57 PM
tomorrow's never coming
tomorrow's never coming - avatar
0
jst edit one line, where you write a=b .. instead of a=b there is b=a... try it... almost all things are correct..
12th Jul 2016, 3:17 PM
siddhpura Amit
siddhpura Amit - avatar