ADVERTISEMENT
ADVERTISEMENT

VB.Net program to demonstrate the right-shift operator (>>)

Here, we are going to demonstrate the right-shift operator (>>) in VB.Net.
Submitted by Nidhi, on November 26, 2020

Here, we will perform a right-shift operation on integer number using a bitwise right-shift operator (>>).

Program/Source Code:

The source code to demonstrate the right-shift operator (>>) is given below. The given program is compiled and executed successfully.

'VB.Net program to demonstrate the right-shift operator.

Module Module1

    Sub Main()
        Dim num As Integer = 0
        Dim res As Integer = 0

        Console.Write("Enter Number: ")
        num = Integer.Parse(Console.ReadLine())

        res = num >> 3
        Console.Write("Result is: {0}", res)

        Console.ReadLine()
    End Sub

End Module

Output:

Enter Number: 64
Result is:8

Explanation:

In the above program, we created a module Module1 that contains a Main() method. And, we created two local variables num and res that are initialized with 0

We entered the value 64 for integer variable num, now we will evaluate the below expression.

res = num >> 3
res = 64 / (23)
res = 64 / 8
res = 8

After that we printed the value of variable 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.