ADVERTISEMENT
ADVERTISEMENT

VB.Net program to perform BITWISE OR operation

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

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

Program/Source Code:

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

'VB.Net program to perform "BITWISE OR" operation.

Module Module1

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

        res = num1 Or num2

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

        Console.ReadLine()
    End Sub

End Module

Output:

Result: 7

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 Or num2

Now evaluate the above expression.

res = num1 Or num2
res = 5 Or 2

The binary equivalent of 5 is 101.

The binary equivalent of 2 is 010.

Then

101
010
====
111

That is 7.

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

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.