×

VB.Net Programs

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

By Nidhi Last Updated : November 13, 2024

Right-shift operator (>>) in VB.Net

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

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

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 »


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.