View previous topic :: View next topic
|
Author |
Message |
sada_polaris
New User
Joined: 24 May 2006 Posts: 13
|
|
|
|
How can values be swapped between 2 variables without using a temporary variable ?
IF A 9(2) has a value of 25 & B 9(2) has value of 50, at the end we shud have A as 50 & B as 25. |
|
Back to top |
|
|
rajandhla
Active User
Joined: 18 Oct 2005 Posts: 182 Location: Luton UK
|
|
|
|
Hi,
Please find the logic
A=5 , B=2
A= A+B (A has value 7)
B= A-B (i.e 7-2=5 B has value 5)
A=A-B (Now 7-5 i.e A has 2)
Hope it helps..........
Regards
jai |
|
Back to top |
|
|
sada_polaris
New User
Joined: 24 May 2006 Posts: 13
|
|
|
|
Thanks a lot Jai for your swift response.
It is working fine.
Thanks
Naveen |
|
Back to top |
|
|
|