Trusted by millions of Kenyans
Study resources on Kenyaplex

Get ready-made curriculum aligned revision materials

Exam papers, notes, holiday assignments and topical questions – all aligned to the Kenyan curriculum.

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

Answer Attachments

Exams With Marking Schemes

Related Questions