VB.Net Program to Print the Binary Number of a Decimal Number

You are currently viewing VB.Net Program to Print the Binary Number of a Decimal Number

VB.Net program to print the binary number of a decimal number

'VB.Net program to print the binary number 
'of a decimal number.

Module Module1
    Sub Main()
        Dim iLoop As SByte
        Dim num As SByte

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

        For iLoop = 7 To 0 Step -1
            If ((1 << iLoop) And num) Then
                Console.Write("1")
            Else
                Console.Write("0")
            End If
        Next

        Console.ReadLine()

    End Sub

End Module

Output

Enter Number: 8
00001000

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply