Want a Free Job Posting?

Buy a job posting today and the second one is on us. For a limited time only. Act Now.

Interview Question

Interview Santa Clara, CA

How can you exchange the value of two variables without

  using a third variable?

Interview Answer

3 Answers


x = x + y y = x - y x = x - y

Interview Candidate on Mar 22, 2011

This post has been removed.
Please see our Community Guidelines or Terms of Service for more information.


int Val1 = 5; int Val2 = 10; Val1 ^= Val2; Val2 ^= Val1; Val1 ^= Val2;

Anonymous on Apr 6, 2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.