ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to perform BITWISE XOR operation

Here, we are going to learn how to perform BITWISE XOR operation in VB.Net?
Submitted by Nidhi, on November 26, 2020

Here, we will perform a BITWISE XOR operation between two integer variables and print the result.

Program/Source Code:

The source code to perform BITWISE XOR operation is given below. The given program is compiled and executed successfully.

'VB.Net program to perform "bitwise xor" operation.

Module Module1

    Sub Main()
        Dim num1 As Integer = 6
        Dim num2 As Integer = 2
        Dim res As Integer = 0

        res = num1 Xor num2

        Console.WriteLine("Result: {0}", res)

        Console.ReadLine()
    End Sub

End Module

Output:

Result: 4

Explanation:

In the above program, we created a module Module1 that contains a function Main(). In the Main() function, we created three local variables num1, num2, and res that are initialized with 5, 2, and 0 respectively.

res = num1 Xor num2

Now evaluate the above expression.

res = num1 Xor num2
res = 6 Xor 2

The binary equivalent of 6 is 110.

The binary equivalent of 2 is 010.

Then

110
010
====
010

That is 4.

At last, we printed the value of res on the console screen.

VB.Net Basic Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.