C# C# Console

Swap the Contents of two Numbers using Bitwise XOR Operation in C#

In this example,i’ll show you How to swap the contents of two numbers using bitwise xor operation in C#.

Here is source code of the C# Program to Swap the Contents of two Numbers using Bitwise XOR Operation. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

In this C# Program, we are reading two integers using ‘i’ and ’k’ integer variables. The bitwise XOR operation is used between ‘i’ and ‘k’ integer variable values. Assign the value to ‘i’ variable and perform the bitwise XOR operation. And assign the value to ‘k’ variable and again to ‘i’ variable. Print the contents of two numbers using bitwise XOR operation.

Output:

[/crayon]

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.