How can I exchange 2 variables values without using any 3rd temporary variable.
Somali Rathore
0
Newbie Poster
Recommended Answers
Jump to Post>How can I exchange 2 variables values without using any 3rd temporary variable.
Most likely your teacher is expecting this:a ^= b; b ^= a; a ^= b;
But I'd recommend you find a new teacher because your current one is likely too focused on archaic …
Jump to PostHow can I exchange 2 variables values without using any 3rd temporary variable.
Let's say you have A=0x10100000 and B=0x00001010 then this is what you do to swap the two variables without using a third variable.
Step 1
_____(A) Exclusive OR (B), when you do this here's …
All 6 Replies
Narue
5,707
Bad Cop
Team Colleague
Salem
commented:
well said
+17
iyercb
5
Newbie Poster
William Hemsworth
commented:
Clear explanation.
+6
Somali Rathore
0
Newbie Poster
Salem
5,138
Posting Sage
ajay.krish123
-4
Junior Poster in Training
Salem
commented:
No it isn't, it's a cheap trick from ASM days, not a useful technique for a HLL
-4
Narue
5,707
Bad Cop
Team Colleague
Freaky_Chris
commented:
Agreed
+4
Salem
commented:
Well said
+17
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.