Get premium membership and access questions with answers, video lessons as well as revision papers.

Write a program to interchange 2 variables without using the third one.

      

Write a program to interchange 2 variables without using the third one.

  

Answers


caroline
a ^= b; ie a=a^b
b ^= a; ie b=b^a;
a ^= b ie a=a^b;
here the numbers are converted into binary and then xor operation is performed.
You know, you're just asking
have you seen this overly clever trick that's not worth applying
on
modern architectures and only really applies to integer variables?
?
carol1 answered the question on April 13, 2018 at 15:39


Next: Differentiate between array and pointer?
Previous: What is a preprocessor, what are the advantages of preprocessor?

View More Computer Science Questions and Answers | Return to Questions Index


Learn High School English on YouTube

Related Questions