Home »
VB.Net »
VB.Net Programs
VB.Net program to demonstrate the left-shift operator (<<)
By Nidhi Last Updated : November 11, 2024
Left-shift operator (<<) in VB.Net
Here, we will perform a left-shift operation on integer number using a bitwise left-shift operator.
VB.Net code to demonstrate the left-shift operator (<<)
The source code to demonstrate the left-shift operator (<<) is given below. The given program is compiled and executed successfully.
'VB.Net program to demonstrate the left-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: 4
Result is: 32
Explanation:
In the above program, we created a module Module1 that contains a Main() method. Here, we created two local variables num and res that are initialized with 0.
Here, we entered the value 4 for integer variable num, now we will evaluate the below expression.
res = num << 3
res = 4 * (23)
res = 4 * 8
res = 32
After that we printed the value of variable res on the console screen.
VB.Net Basic Programs »