ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to demonstrate the left-shift operator (<<)

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

Here, we will perform a left-shift operation on integer number using a bitwise left-shift operator.

Program/Source Code:

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 »



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.