iam a 1st yr b.e stucent.i was attending my c.p lab viva.i was asked to write a program that would exchange 2 variables without using a third variable.i could'nt do it.i know how to exchange the values by using a third variable.someone please answer this question.
abcd_nima
0
Newbie Poster
Recommended Answers
Jump to PostIt's fairly simple to write:
int a=5; int b=3; a = a ^ b; // a will contain a xor b = 6 b = a ^ b; // b will receive 6 xor 3 = 5 a = a ^ b; // a will become 6 …
All 2 Replies
Nick Evan
4,005
Industrious Poster
Team Colleague
Featured Poster
hammerhead
commented:
I did not know this method existed :)
+2
hammerhead
19
Posting Whiz in Training
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.